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