Migration: Fix contacts and bookmarks
This commit is contained in:
parent
77b7f214d2
commit
426193cf6c
|
@ -40,8 +40,8 @@ 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 = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
|
$bookmarkquery = 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'] ) );
|
$bookmarkquery->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
|
||||||
// Map the id
|
// Map the id
|
||||||
$idmap[$row['id']] = OCP\DB::insertid();
|
$idmap[$row['id']] = OCP\DB::insertid();
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ 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 = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
|
$tagquery = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
|
||||||
$query->execute( array( $newid, $row['tag'] ) );
|
$tagquery->execute( array( $newid, $row['tag'] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All done!
|
// All done!
|
||||||
|
|
|
@ -40,19 +40,20 @@ class OC_Migration_Provider_Contacts 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 = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" );
|
$addressbookquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" );
|
||||||
$query->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) );
|
$addressbookquery->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) );
|
||||||
// Map the id
|
// Map the id
|
||||||
$idmap[$row['id']] = OCP\DB::insertid();
|
$idmap[$row['id']] = OCP\DB::insertid();
|
||||||
}
|
}
|
||||||
// Now tags
|
// Now tags
|
||||||
foreach($idmap as $oldid => $newid){
|
foreach($idmap as $oldid => $newid){
|
||||||
|
|
||||||
$query = $this->content->prepare( "SELECT * FROM contacts_cards WHERE addressbookid LIKE ?" );
|
$query = $this->content->prepare( "SELECT * FROM contacts_cards WHERE addressbookid LIKE ?" );
|
||||||
$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 = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" );
|
$contactquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" );
|
||||||
$query->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) );
|
$contactquery->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All done!
|
// All done!
|
||||||
|
|
Loading…
Reference in New Issue