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;
|
||||
|
||||
|
||||
/*if( ! (is_array($data) || is_object($data)))
|
||||
if( ! (is_array($data) || is_object($data)))
|
||||
{
|
||||
trigger_error("Invalid data argument");
|
||||
return FALSE;
|
||||
}*/
|
||||
}
|
||||
|
||||
// Bind the parameters
|
||||
foreach($data as $k => $value)
|
||||
@ -125,15 +125,18 @@ abstract class DB_PDO extends PDO {
|
||||
* @param PDOStatement $statement
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows($statement)
|
||||
public function affected_rows($statement='')
|
||||
{
|
||||
$this->statement = $statement;
|
||||
|
||||
if ( ! empty($statement))
|
||||
{
|
||||
$this->statement = $statement;
|
||||
}
|
||||
|
||||
// Execute the query
|
||||
$this->statement->execute();
|
||||
|
||||
// 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
|
||||
$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,
|
||||
// but no support for the actual command.
|
||||
$sql = 'DELETE FROM :table';
|
||||
$sql = 'DELETE FROM "'.$table.'"';
|
||||
|
||||
$this->prepare_query($sql, array(
|
||||
':table' => $table
|
||||
));
|
||||
|
||||
$this->statement->execute();
|
||||
$this->statement = $this->query($sql);
|
||||
|
||||
return $this->statement;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -103,6 +103,13 @@ class FirebirdTest extends UnitTestCase {
|
||||
$this->assertTrue($table_exists);
|
||||
}*/
|
||||
|
||||
function TestTruncate()
|
||||
{
|
||||
$this->db->truncate('create_test');
|
||||
|
||||
$this->assertTrue($this->db->affected_rows() > 0);
|
||||
}
|
||||
|
||||
function TestCommitTransaction()
|
||||
{
|
||||
$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 )');
|
||||
}
|
||||
|
||||
function TestTruncate()
|
||||
{
|
||||
$this->db->truncate('create_test');
|
||||
$this->assertIsA($this->db->affected_rows(), 'int');
|
||||
}
|
||||
|
||||
function TestPreparedStatements()
|
||||
{
|
||||
$sql = <<<SQL
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user