From f78765f494ba7b82dcb943bc7e9b4926483c9b30 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 19 Mar 2012 20:44:20 +0000 Subject: [PATCH] Add OC_Migration_Content class to help app devs. Restructure OC_Migrate. --- lib/migrate.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/migrate.php b/lib/migrate.php index ffc5e9f8..36a08c0c 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -1,16 +1,16 @@ 'bookmarks', 'matchcol'=>'user_id', - 'matchval'=>$uid, + 'matchval'=>$this->uid, 'idcol'=>'id' ); - $ids = OC_Migrate::copyRows( $options ); + $ids = $this->content->copyRows( $options ); $options = array( 'table'=>'bookmarks_tags', @@ -19,7 +19,7 @@ class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{ ); // Export tags - $ids2 = OC_Migrate::copyRows( $options ); + $ids2 = $this->content->copyRows( $options ); // If both returned some ids then they worked if( is_array( $ids ) && is_array( $ids2 ) ) @@ -32,17 +32,17 @@ class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{ } // Import function for bookmarks - function import( $app, $info ){ - switch( $app->version ){ + function import( ){ + switch( $this->appinfo->version ){ default: // All versions of the app have had the same db structure, so all can use the same import function $query = OC_Migrate::prepare( "SELECT * FROM bookmarks WHERE user_id LIKE ?" ); - $results = $query->execute( array( $info['olduid'] ) ); + $results = $query->execute( array( $this->info['olduid'] ) ); $idmap = array(); while( $row = $data->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->execute( array( $row['url'], $row['title'], $info['newuid'], $row['public'], $row['added'], $row['lastmodified'] ) ); + $query->execute( array( $row['url'], $row['title'], $this->info['newuid'], $row['public'], $row['added'], $row['lastmodified'] ) ); // Map the id $idmap[$row['id']] = OC_DB::insertid(); } @@ -66,4 +66,4 @@ class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{ } // Load the provider -new OC_Migrate_Provider_Bookmarks( 'bookmarks' ); \ No newline at end of file +new OC_Migration_Provider_Bookmarks( 'bookmarks' ); \ No newline at end of file