From 124f34422c3b488869e0348c97d87aa0a69a3fe9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= <jfd@butonic.de>
Date: Mon, 10 Jun 2013 09:53:29 +0200
Subject: [PATCH] add missing backticks all over the place

---
 apps/files_encryption/lib/util.php    |  8 ++++----
 lib/files/cache/backgroundwatcher.php |  4 ++--
 lib/files/cache/cache.php             |  6 +++---
 lib/public/share.php                  | 12 ++++++------
 tests/lib/db.php                      | 22 +++++++++++-----------
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 04bd4dc8ac..a6711880c2 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -289,7 +289,7 @@ class Util {
 	 */
 	public function recoveryEnabledForUser() {
 
-		$sql = 'SELECT `recovery_enabled` FROM `*PREFIX*encryption` WHERE  uid = ?';
+		$sql = 'SELECT `recovery_enabled` FROM `*PREFIX*encryption` WHERE `uid` = ?';
 
 		$args = array($this->userId);
 
@@ -347,7 +347,7 @@ class Util {
 			// Create a new record instead
 		} else {
 
-			$sql = 'UPDATE `*PREFIX*encryption` SET recovery_enabled = ? WHERE uid = ?';
+			$sql = 'UPDATE `*PREFIX*encryption` SET `recovery_enabled` = ? WHERE `uid` = ?';
 
 			$args = array(
 				$enabled,
@@ -1060,7 +1060,7 @@ class Util {
 	 */
 	public function setMigrationStatus($status) {
 
-		$sql = 'UPDATE `*PREFIX*encryption` SET migration_status = ? WHERE uid = ?';
+		$sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?';
 
 		$args = array(
 			$status,
@@ -1089,7 +1089,7 @@ class Util {
 	 */
 	public function getMigrationStatus() {
 
-		$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption`  WHERE uid = ?';
+		$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?';
 
 		$args = array($this->userId);
 
diff --git a/lib/files/cache/backgroundwatcher.php b/lib/files/cache/backgroundwatcher.php
index 8933101577..8e68f41cf4 100644
--- a/lib/files/cache/backgroundwatcher.php
+++ b/lib/files/cache/backgroundwatcher.php
@@ -59,9 +59,9 @@ class BackgroundWatcher {
 	 */
 	static private function getNextFileId($previous, $folder) {
 		if ($folder) {
-			$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND mimetype = ' . self::getFolderMimetype() . ' ORDER BY `fileid` ASC', 1);
+			$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND `mimetype` = ' . self::getFolderMimetype() . ' ORDER BY `fileid` ASC', 1);
 		} else {
-			$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND mimetype != ' . self::getFolderMimetype() . ' ORDER BY `fileid` ASC', 1);
+			$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND `mimetype` != ' . self::getFolderMimetype() . ' ORDER BY `fileid` ASC', 1);
 		}
 		$result = $query->execute(array($previous));
 		if ($row = $result->fetchRow()) {
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index cae2e63e4d..6c2ef71098 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -241,7 +241,7 @@ class Cache {
 		$params[] = $id;
 
 		$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=?'
-			. ' WHERE fileid = ?');
+			. ' WHERE `fileid` = ?');
 		$query->execute($params);
 	}
 
@@ -385,10 +385,10 @@ class Cache {
 	 * remove all entries for files that are stored on the storage from the cache
 	 */
 	public function clear() {
-		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache` WHERE storage = ?');
+		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?');
 		$query->execute(array($this->getNumericStorageId()));
 
-		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*storages` WHERE id = ?');
+		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*storages` WHERE `id` = ?');
 		$query->execute(array($this->storageId));
 	}
 
diff --git a/lib/public/share.php b/lib/public/share.php
index 81f5515bb4..6a26101a1c 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -152,11 +152,11 @@ class Share {
 
 			// Fetch all shares of this file path from DB
 			$query = \OC_DB::prepare(
-				'SELECT share_with
+				'SELECT `share_with`
 				FROM
 				`*PREFIX*share`
 				WHERE
-				item_source = ? AND share_type = ?'
+				`item_source` = ? AND `share_type` = ?'
 			);
 
 			$result = $query->execute(array($source, self::SHARE_TYPE_USER));
@@ -171,11 +171,11 @@ class Share {
 			// We also need to take group shares into account
 
 			$query = \OC_DB::prepare(
-				'SELECT share_with
+				'SELECT `share_with`
 				FROM
 				`*PREFIX*share`
 				WHERE
-				item_source = ? AND share_type = ?'
+				`item_source` = ? AND `share_type` = ?'
 			);
 
 			$result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
@@ -192,11 +192,11 @@ class Share {
 			//check for public link shares
 			if (!$publicShare) {
 				$query = \OC_DB::prepare(
-					'SELECT share_with
+					'SELECT `share_with`
 					FROM
 					`*PREFIX*share`
 					WHERE
-					item_source = ? AND share_type = ?'
+					`item_source` = ? AND `share_type` = ?'
 				);
 
 				$result = $query->execute(array($source, self::SHARE_TYPE_LINK));
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 440f3fb6bf..eff01bd906 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -33,15 +33,15 @@ class Test_DB extends PHPUnit_Framework_TestCase {
 	}
 
 	public function testQuotes() {
-		$query = OC_DB::prepare('SELECT `fullname` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array('uri_1'));
 		$this->assertTrue((bool)$result);
 		$row = $result->fetchRow();
 		$this->assertFalse($row);
-		$query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (?,?)');
+		$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
 		$result = $query->execute(array('fullname test', 'uri_1'));
 		$this->assertTrue((bool)$result);
-		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array('uri_1'));
 		$this->assertTrue((bool)$result);
 		$row = $result->fetchRow();
@@ -52,19 +52,19 @@ class Test_DB extends PHPUnit_Framework_TestCase {
 	}
 
 	public function testNOW() {
-		$query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (NOW(),?)');
+		$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)');
 		$result = $query->execute(array('uri_2'));
 		$this->assertTrue((bool)$result);
-		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array('uri_2'));
 		$this->assertTrue((bool)$result);
 	}
 
 	public function testUNIX_TIMESTAMP() {
-		$query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)');
+		$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)');
 		$result = $query->execute(array('uri_3'));
 		$this->assertTrue((bool)$result);
-		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array('uri_3'));
 		$this->assertTrue((bool)$result);
 	}
@@ -88,7 +88,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
 			$this->assertTrue((bool)$result);
 		}
 
-		$query = OC_DB::prepare('SELECT * FROM *PREFIX*'.$this->table3);
+		$query = OC_DB::prepare('SELECT * FROM `*PREFIX*'.$this->table3.'`');
 		$result = $query->execute();
 		$this->assertTrue((bool)$result);
 		$this->assertEquals('4', $result->numRows());
@@ -100,10 +100,10 @@ class Test_DB extends PHPUnit_Framework_TestCase {
 		$carddata = 'This is a vCard';
 
 		// Normal test to have same known data inserted.
-		$query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)');
+		$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)');
 		$result = $query->execute(array($fullname, $uri, $carddata));
 		$this->assertTrue((bool)$result);
-		$query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array($uri));
 		$this->assertTrue((bool)$result);
 		$row = $result->fetchRow();
@@ -119,7 +119,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
 			));
 		$this->assertTrue((bool)$result);
 
-		$query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+		$query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
 		$result = $query->execute(array($uri));
 		$this->assertTrue((bool)$result);
 		$row = $result->fetchRow();
-- 
GitLab