mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-01-18 14:52:10 +01:00
ported oc_db
This commit is contained in:
parent
330e1f5a85
commit
7bfe6a7c89
@ -35,7 +35,7 @@ $params=array(
|
||||
OCP\USER::getUser()
|
||||
);
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
SELECT id FROM *PREFIX*bookmarks
|
||||
WHERE url LIKE ?
|
||||
AND user_id = ?
|
||||
@ -43,7 +43,7 @@ $query = OC_DB::prepare("
|
||||
|
||||
$id = $query->execute($params)->fetchOne();
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
DELETE FROM *PREFIX*bookmarks
|
||||
WHERE id = $id
|
||||
");
|
||||
@ -51,7 +51,7 @@ $query = OC_DB::prepare("
|
||||
$result = $query->execute();
|
||||
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
DELETE FROM *PREFIX*bookmarks_tags
|
||||
WHERE bookmark_id = $id
|
||||
");
|
||||
|
@ -41,7 +41,7 @@ if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||
|
||||
$bookmark_id = (int)$_GET["id"];
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
UPDATE *PREFIX*bookmarks
|
||||
SET url = ?, title =?, lastmodified = $_ut
|
||||
WHERE id = $bookmark_id
|
||||
@ -54,14 +54,14 @@ $params=array(
|
||||
$query->execute($params);
|
||||
|
||||
# Remove old tags and insert new ones.
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
DELETE FROM *PREFIX*bookmarks_tags
|
||||
WHERE bookmark_id = $bookmark_id
|
||||
");
|
||||
|
||||
$query->execute();
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
(bookmark_id, tag)
|
||||
VALUES (?, ?)
|
||||
|
@ -30,7 +30,7 @@ $RUNTIME_NOSETUPFS=true;
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('bookmarks');
|
||||
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
UPDATE *PREFIX*bookmarks
|
||||
SET clickcount = clickcount + 1
|
||||
WHERE user_id = ?
|
||||
|
6
appinfo/migrate.php
Normal file → Executable file
6
appinfo/migrate.php
Normal file → Executable file
@ -40,10 +40,10 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
|
||||
$idmap = array();
|
||||
while( $row = $results->fetchRow() ){
|
||||
// Import each bookmark, saving its id into the map
|
||||
$query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
|
||||
$query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
|
||||
$query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
|
||||
// Map the id
|
||||
$idmap[$row['id']] = OC_DB::insertid();
|
||||
$idmap[$row['id']] = OCP\DB::insertid();
|
||||
}
|
||||
// Now tags
|
||||
foreach($idmap as $oldid => $newid){
|
||||
@ -51,7 +51,7 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
|
||||
$results = $query->execute( array( $oldid ) );
|
||||
while( $row = $results->fetchRow() ){
|
||||
// Import the tags for this bookmark, using the new bookmark id
|
||||
$query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
|
||||
$query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
|
||||
$query->execute( array( $newid, $row['tag'] ) );
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ function addBookmark($url, $title, $tags='') {
|
||||
}
|
||||
|
||||
//FIXME: Detect when user adds a known URL
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks
|
||||
(url, title, user_id, public, added, lastmodified)
|
||||
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
||||
@ -105,10 +105,10 @@ function addBookmark($url, $title, $tags='') {
|
||||
);
|
||||
$query->execute($params);
|
||||
|
||||
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
|
||||
$b_id = OCP\DB::insertid('*PREFIX*bookmarks');
|
||||
|
||||
if($b_id !== false) {
|
||||
$query = OC_DB::prepare("
|
||||
$query = OCP\DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
(bookmark_id, tag)
|
||||
VALUES (?, ?)
|
||||
|
@ -70,7 +70,7 @@ class OC_Bookmarks_Bookmarks{
|
||||
}
|
||||
|
||||
if($CONFIG_DBTYPE == 'pgsql' ){
|
||||
$query = OC_DB::prepare('
|
||||
$query = OCP\DB::prepare('
|
||||
SELECT id, url, title, '.($filterTagOnly?'':'url || title ||').' array_to_string(array_agg(tag), \' \') as tags
|
||||
FROM *PREFIX*bookmarks
|
||||
LEFT JOIN *PREFIX*bookmarks_tags ON *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
|
||||
@ -87,7 +87,7 @@ class OC_Bookmarks_Bookmarks{
|
||||
else
|
||||
$concatFunction = 'Concat(Concat( url, title), ';
|
||||
|
||||
$query = OC_DB::prepare('
|
||||
$query = OCP\DB::prepare('
|
||||
SELECT id, url, title, '
|
||||
.($filterTagOnly?'':$concatFunction).
|
||||
'CASE WHEN *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
|
||||
|
Loading…
x
Reference in New Issue
Block a user