diff --git a/appinfo/migrate.php b/appinfo/migrate.php index 2559b4ea..19c960c7 100644 --- a/appinfo/migrate.php +++ b/appinfo/migrate.php @@ -34,12 +34,12 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ 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 = $this->content->prepare( "SELECT * FROM contacts_addressbooks WHERE userid LIKE ?" ); + $query = $this->content->prepare( 'SELECT * FROM `contacts_addressbooks` WHERE `userid` LIKE ?' ); $results = $query->execute( array( $this->olduid ) ); $idmap = array(); while( $row = $results->fetchRow() ) { // Import each addressbook - $addressbookquery = 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 (?, ?, ?, ?, ?)' ); $addressbookquery->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) ); // Map the id $idmap[$row['id']] = OCP\DB::insertid('*PREFIX*contacts_addressbooks'); @@ -49,11 +49,11 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ // Now tags 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 ) ); while( $row = $results->fetchRow() ){ // Import the contacts - $contactquery = 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 (?, ?, ?, ?, ?)' ); $contactquery->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) ); } } diff --git a/appinfo/update.php b/appinfo/update.php index 21e736bb..cc00b325 100644 --- a/appinfo/update.php +++ b/appinfo/update.php @@ -3,15 +3,15 @@ $installedVersion=OCP\Config::getAppValue('contacts', 'installed_version'); if (version_compare($installedVersion, '0.2.3', '<')) { // First set all address books in-active. - $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET active=0' ); + $stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=0' ); $result = $stmt->execute(array()); // Then get all the active address books. - $stmt = OCP\DB::prepare( 'SELECT userid,configvalue FROM *PREFIX*preferences WHERE appid=\'contacts\' AND configkey=\'openaddressbooks\'' ); + $stmt = OCP\DB::prepare( 'SELECT `userid`,`configvalue` FROM `*PREFIX*preferences` WHERE `appid`=\'contacts\' AND `configkey`=\'openaddressbooks\'' ); $result = $stmt->execute(array()); // Prepare statement for updating the new 'active' field. - $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET active=? WHERE id=? AND userid=?' ); + $stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=? WHERE `id`=? AND `userid`=?' ); while( $row = $result->fetchRow()) { $ids = explode(';', $row['configvalue']); foreach($ids as $id) { @@ -20,6 +20,6 @@ if (version_compare($installedVersion, '0.2.3', '<')) { } // Remove the old preferences. - $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE appid=\'contacts\' AND configkey=\'openaddressbooks\'' ); + $stmt = OCP\DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid`=\'contacts\' AND `configkey`=\'openaddressbooks\'' ); $result = $stmt->execute(array()); } diff --git a/lib/share/addressbook.php b/lib/share/addressbook.php index d35f0ce9..acabeab2 100644 --- a/lib/share/addressbook.php +++ b/lib/share/addressbook.php @@ -82,7 +82,7 @@ class OC_Share_Backend_Addressbook implements OCP\Share_Backend_Collection { } public function getChildren($itemSource) { - $query = OCP\DB::prepare('SELECT id FROM *PREFIX*contacts_cards WHERE addressbookid = ?'); + $query = OCP\DB::prepare('SELECT `id` FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ?'); $result = $query->execute(array($itemSource)); $sources = array(); while ($contact = $result->fetchRow()) { diff --git a/lib/vcard.php b/lib/vcard.php index fbb1c734..042ad1e9 100644 --- a/lib/vcard.php +++ b/lib/vcard.php @@ -512,7 +512,7 @@ class OC_Contacts_VCard { public static function deleteFromDAVData($aid,$uri){ $addressbook = OC_Contacts_Addressbook::find($aid); if ($addressbook['userid'] != OCP\User::getUser()) { - $query = OCP\DB::prepare( 'SELECT id FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' ); + $query = OCP\DB::prepare( 'SELECT `id` FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? AND `uri` = ?' ); $id = $query->execute(array($aid, $uri))->fetchOne(); if (!$id) { return false;