Added truncate tests to firebird/sqlite test suites
This commit is contained in:
parent
9d33c5e8f0
commit
d74e1907dd
@ -54,11 +54,11 @@ abstract class DB_PDO extends PDO {
|
|||||||
$this->statement =& $query;
|
$this->statement =& $query;
|
||||||
|
|
||||||
|
|
||||||
/*if( ! (is_array($data) || is_object($data)))
|
if( ! (is_array($data) || is_object($data)))
|
||||||
{
|
{
|
||||||
trigger_error("Invalid data argument");
|
trigger_error("Invalid data argument");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Bind the parameters
|
// Bind the parameters
|
||||||
foreach($data as $k => $value)
|
foreach($data as $k => $value)
|
||||||
@ -125,15 +125,18 @@ abstract class DB_PDO extends PDO {
|
|||||||
* @param PDOStatement $statement
|
* @param PDOStatement $statement
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function affected_rows($statement)
|
public function affected_rows($statement='')
|
||||||
{
|
{
|
||||||
$this->statement = $statement;
|
if ( ! empty($statement))
|
||||||
|
{
|
||||||
|
$this->statement = $statement;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute the query
|
// Execute the query
|
||||||
$this->statement->execute();
|
$this->statement->execute();
|
||||||
|
|
||||||
// Return number of rows affected
|
// Return number of rows affected
|
||||||
return $this->statement->rowCount;
|
return $this->statement->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -65,7 +65,7 @@ class firebird extends DB_PDO {
|
|||||||
{
|
{
|
||||||
// Firebird lacka a truncate command
|
// Firebird lacka a truncate command
|
||||||
$sql = 'DELETE FROM "'.$table.'"';
|
$sql = 'DELETE FROM "'.$table.'"';
|
||||||
$this->query($sql);
|
$this->statement = $this->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -46,13 +46,11 @@ class SQLite extends DB_PDO {
|
|||||||
{
|
{
|
||||||
// SQLite has a TRUNCATE optimization,
|
// SQLite has a TRUNCATE optimization,
|
||||||
// but no support for the actual command.
|
// but no support for the actual command.
|
||||||
$sql = 'DELETE FROM :table';
|
$sql = 'DELETE FROM "'.$table.'"';
|
||||||
|
|
||||||
$this->prepare_query($sql, array(
|
$this->statement = $this->query($sql);
|
||||||
':table' => $table
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->statement->execute();
|
return $this->statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -103,6 +103,13 @@ class FirebirdTest extends UnitTestCase {
|
|||||||
$this->assertTrue($table_exists);
|
$this->assertTrue($table_exists);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
function TestTruncate()
|
||||||
|
{
|
||||||
|
$this->db->truncate('create_test');
|
||||||
|
|
||||||
|
$this->assertTrue($this->db->affected_rows() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
function TestCommitTransaction()
|
function TestCommitTransaction()
|
||||||
{
|
{
|
||||||
$res = $this->db->beginTransaction();
|
$res = $this->db->beginTransaction();
|
||||||
|
@ -79,6 +79,12 @@ class SQLiteTest extends UnitTestCase {
|
|||||||
$this->assertEqual($dbs['create_test'], 'CREATE TABLE "create_test" (id INTEGER PRIMARY KEY, key TEXT , val TEXT )');
|
$this->assertEqual($dbs['create_test'], 'CREATE TABLE "create_test" (id INTEGER PRIMARY KEY, key TEXT , val TEXT )');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TestTruncate()
|
||||||
|
{
|
||||||
|
$this->db->truncate('create_test');
|
||||||
|
$this->assertIsA($this->db->affected_rows(), 'int');
|
||||||
|
}
|
||||||
|
|
||||||
function TestPreparedStatements()
|
function TestPreparedStatements()
|
||||||
{
|
{
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user