Various tweaks

This commit is contained in:
Timothy Warren 2012-04-18 16:28:12 -04:00
parent 12f53c5fd5
commit 5d5588c909
7 changed files with 37 additions and 9 deletions

View File

@ -171,9 +171,9 @@ abstract class DB_PDO extends PDO {
*/
public function get_last_error()
{
$info = $this->errorInfo();
list($i1, $i2, $i3) = $this->errorInfo();
echo "Error: <pre>{$info[0]}:{$info[1]}\n{$info[2]}</pre>";
echo "Error: <pre>{$i1}:{$i2}\n{$i3}</pre>";
}
// --------------------------------------------------------------------------

View File

@ -27,6 +27,24 @@ abstract class DB_Util {
$this->conn =& $conn;
}
// --------------------------------------------------------------------------
/**
* Enable calling driver methods
*
* @param string $method
* @param array $args
*/
public function __call($method, $args)
{
if (method_exists($this->conn, $method))
{
return call_user_func_array(array($this->conn, $method), $args);
}
return NULL;
}
// --------------------------------------------------------------------------
// ! Abstract Methods
// --------------------------------------------------------------------------

View File

@ -140,9 +140,12 @@ class Firebird_Util extends DB_Util {
{
$sql = 'SELECT * FROM "'.trim($t).'"';
$res = $this->query($sql);
$obj_res = $this->fetchAll(PDO::FETCH_ASSOC);
unset($res);
$obj_res = $res->fetchAll(PDO::FETCH_ASSOC);
// Don't add to the file if the table is empty
if (count($obj_res) < 1) continue;
$res = NULL;
// Nab the column names by getting the keys of the first row
$columns = @array_keys($obj_res[0]);
@ -163,12 +166,12 @@ class Firebird_Util extends DB_Util {
$row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');';
unset($row);
$row = NULL;
$insert_rows[] = $row_string;
}
unset($obj_res);
$obj_res = NULL;
$output_sql .= "\n\nSET TRANSACTION;\n".implode("\n", $insert_rows)."\nCOMMIT;";
}

View File

@ -121,10 +121,13 @@ class MySQL_Util extends DB_Util {
/**
* Create an SQL backup file for the current database's data
*
* @param array $exclude
* @return string
*/
public function backup_data()
public function backup_data($exclude=array())
{
$tables = $this->get_tables();
// @todo Implement Backup function
return '';
}

View File

@ -48,5 +48,10 @@ abstract class DBTest extends UnitTestCase {
$res = $this->db->beginTransaction();
$this->assertTrue($res);
}
function TestBackupData()
{
$this->assertTrue(is_string($this->db->util->backup_data()));
}
}
// End of db_test.php

View File

@ -187,5 +187,4 @@ SQL;
{
$this->assertTrue(is_array($this->db->get_triggers()));
}
}

Binary file not shown.