diff --git a/classes/db/DBSqlite3_pdo.class.php b/classes/db/DBSqlite3_pdo.class.php index 34aecd172..18926963b 100644 --- a/classes/db/DBSqlite3_pdo.class.php +++ b/classes/db/DBSqlite3_pdo.class.php @@ -74,7 +74,7 @@ $db_info = Context::getDBInfo(); $this->database = $db_info->master_db["db_database"]; $this->prefix = $db_info->master_db["db_table_prefix"]; - if(!substr($this->prefix,-1)!='_') $this->prefix .= '_'; + //if(!substr($this->prefix,-1)!='_') $this->prefix .= '_'; } /** @@ -130,7 +130,13 @@ **/ function commit($force = false) { if(!$force && (!$this->is_connected || !$this->transaction_started)) return; - $this->handler->commit(); + try { + $this->handler->commit(); + } + catch(PDOException $e){ + // There was no transaction started, so just continue. + error_log($e->getMessage()); + } $this->transaction_started = false; } @@ -403,6 +409,10 @@ } } + function _getConnection($type = null){ + return null; + } + /** * @brief insertAct * */ @@ -457,6 +467,7 @@ $this->_prepare($query); $data = $this->_execute(); + // TODO isError is called twice if ($this->isError()) return; diff --git a/test-phpUnit/config/config.inc.php b/test-phpUnit/config/config.inc.php index 6ee61f7cf..0b61fbc7f 100644 --- a/test-phpUnit/config/config.inc.php +++ b/test-phpUnit/config/config.inc.php @@ -15,6 +15,7 @@ require_once(_XE_PATH_.'test-phpUnit/db/MssqlTest.php'); require_once(_XE_PATH_.'test-phpUnit/db/MssqlOnlineTest.php'); require_once(_XE_PATH_.'test-phpUnit/db/MysqlTest.php'); + require_once(_XE_PATH_.'test-phpUnit/db/SqliteTest.php'); require_once(_XE_PATH_.'config/config.inc.php'); // require_once(_XE_PATH_.'classes/object/Object.class.php'); diff --git a/test-phpUnit/db/DBTest.php b/test-phpUnit/db/DBTest.php index 59f5c4a3f..94b36e13e 100644 --- a/test-phpUnit/db/DBTest.php +++ b/test-phpUnit/db/DBTest.php @@ -29,7 +29,7 @@ echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL; echo $xml_file; echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL; - + $tester = new QueryTester(); $outputString = $tester->getNewParserOutputString($xml_file, $argsString); echo $outputString; diff --git a/test-phpUnit/db/SqliteTest.php b/test-phpUnit/db/SqliteTest.php new file mode 100644 index 000000000..edb62d647 --- /dev/null +++ b/test-phpUnit/db/SqliteTest.php @@ -0,0 +1,32 @@ +master_db = array('db_type' => 'sqlite3_pdo','db_table_prefix' => 'xe_'); + $db_info->slave_db = array(array('db_type' => 'sqlite3_pdo','db_table_prefix' => 'xe_')); + + $oContext->setDbInfo($db_info); + DB::getParser(true); + } + + /** + * Free resources - reset static DB and QueryParser + */ + protected function tearDown() { + unset($GLOBALS['__DB__']); + } + } +?> diff --git a/test-phpUnit/db/xml_query/sqlite/SqliteDeleteTest.php b/test-phpUnit/db/xml_query/sqlite/SqliteDeleteTest.php new file mode 100644 index 000000000..9e575af90 --- /dev/null +++ b/test-phpUnit/db/xml_query/sqlite/SqliteDeleteTest.php @@ -0,0 +1,18 @@ +_testQuery($xml_file, $argsString, $expected, 'getDeleteSql', $columnList); + } + + function testDeleteIsGeneratedWithoutAlias(){ + $xml_file = _TEST_PATH_ . "db/xml_query/sqlite/data/module.deleteModuleConfig.xml"; + $argsString = '$args->module = "comment"; $args->site_srl = 0; '; + $expected = 'delete from "xe_module_config" + where "module" = \'comment\' and "site_srl" = 0'; + $this->_test($xml_file, $argsString, $expected); + } + + } \ No newline at end of file diff --git a/test-phpUnit/db/xml_query/sqlite/SqliteUpdateTest.php b/test-phpUnit/db/xml_query/sqlite/SqliteUpdateTest.php new file mode 100644 index 000000000..28a3d0567 --- /dev/null +++ b/test-phpUnit/db/xml_query/sqlite/SqliteUpdateTest.php @@ -0,0 +1,22 @@ +_testQuery($xml_file, $argsString, $expected, 'getUpdateSql', $columnList); + } + + function testUpdateIsGeneratedWithoutAlias(){ + $xml_file = _TEST_PATH_ . "db/xml_query/sqlite/data/member.updateLastLogin.xml"; + $argsString = '$args->member_srl = 4; + $args->last_login = \'20111014184010\'; + '; + $expected = 'UPDATE "xe_member" + SET "member_srl" = 4 + , "last_login" = \'20111014184010\' + WHERE "member_srl" = 4'; + $this->_test($xml_file, $argsString, $expected); + } + + } \ No newline at end of file diff --git a/test-phpUnit/db/xml_query/sqlite/data/member.updateLastLogin.xml b/test-phpUnit/db/xml_query/sqlite/data/member.updateLastLogin.xml new file mode 100644 index 000000000..3a8fde69d --- /dev/null +++ b/test-phpUnit/db/xml_query/sqlite/data/member.updateLastLogin.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/test-phpUnit/db/xml_query/sqlite/data/module.deleteModuleConfig.xml b/test-phpUnit/db/xml_query/sqlite/data/module.deleteModuleConfig.xml new file mode 100644 index 000000000..bdc99660b --- /dev/null +++ b/test-phpUnit/db/xml_query/sqlite/data/module.deleteModuleConfig.xml @@ -0,0 +1,9 @@ + + +
+ + + + + +