aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/dba/dba_pdo.php3
-rw-r--r--tests/unit/includes/dba/dba_pdoTest.php22
2 files changed, 24 insertions, 1 deletions
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index 719f23c4b..f24c5381a 100755
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -66,8 +66,9 @@ class dba_pdo extends dba_driver {
}
}
+ $result = null;
$this->error = '';
- $select = ((stripos($sql,'select') === 0) ? true : false);
+ $select = ((stripos($sql, 'select') === 0) ? true : false);
try {
$result = $this->db->query($sql, PDO::FETCH_ASSOC);
diff --git a/tests/unit/includes/dba/dba_pdoTest.php b/tests/unit/includes/dba/dba_pdoTest.php
index ce6e1ffd6..12e574d42 100644
--- a/tests/unit/includes/dba/dba_pdoTest.php
+++ b/tests/unit/includes/dba/dba_pdoTest.php
@@ -164,4 +164,26 @@ class dba_pdoTest extends DatabaseTestCase {
$this->assertFalse($nodba->q('SELECT * FROM account'));
}
+ /**
+ * @depends testConnectToSqlServer
+ */
+ public function testSelectQueryToNonExistentTableShouldReturnFalse() {
+ $ret = $this->dba->q('SELECT * FROM non_existent_table');
+
+ $this->assertFalse($ret);
+ }
+
+ /**
+ * @depends testConnectToSqlServer
+ */
+ public function testInsertQueryToNonExistentTableShouldReturnEmptyArray() {
+ $ret = $this->dba->q('INSERT INTO non_existent_table
+ (account_email, account_language)
+ VALUES (\'email@example.com\', \'en\')
+ ');
+
+ $this->assertNotInstanceOf('PDOStatement', $ret);
+ $this->isEmpty($ret);
+ }
+
}