From 7600e5634e393099ce2712e860124e2f00a40004 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 6 Feb 2012 16:56:16 -0500 Subject: [PATCH] More DB driver updateds --- .gitignore | 3 +-- src/databases/db_pdo.php | 28 ++++++++++++++++++++++++++++ src/databases/firebird.php | 31 +++++++++++++++++++++++++++++++ src/databases/mysql.php | 20 ++++++++++++++++++++ src/databases/odbc.php | 20 ++++++++++++++++++++ src/databases/pgsql.php | 20 ++++++++++++++++++++ src/databases/sqlite.php | 23 ++++++++++++++++++++++- 7 files changed, 142 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b10d5da..0aea446 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ *.DS_Store settings.json errors.txt -*/simpletest/* - +*/simpletest/* \ No newline at end of file diff --git a/src/databases/db_pdo.php b/src/databases/db_pdo.php index accb3d4..816f1f7 100644 --- a/src/databases/db_pdo.php +++ b/src/databases/db_pdo.php @@ -111,8 +111,36 @@ abstract class DB_PDO extends PDO { /** * Abstract functions to override in child classes */ + + /** + * Return list of tables for the current database + * + * @return array + */ abstract function get_tables(); + + /** + * Empty the passed table + * + * @param string $table + * + * @return void + */ abstract function truncate($table); + /** + * Return the number of rows for the last SELECT query + * + * @return int + */ + abstract function num_rows(); + + /** + * Return the number of rows affected by the last query + * + * @return int + */ + abstract function affected_rows(); + } // End of db_pdo.php \ No newline at end of file diff --git a/src/databases/firebird.php b/src/databases/firebird.php index aa363be..0acd816 100644 --- a/src/databases/firebird.php +++ b/src/databases/firebird.php @@ -86,6 +86,17 @@ class firebird { //TODO implement } + /** + * Emulate PDO prepare + * + * @return resource + */ + function prepare() + { + $this->statement = ibase_prepare($this->conn, $query); + return $this->statement; + } + /** * List tables for the current database * @@ -96,6 +107,26 @@ class firebird { $sql="SELECT rdb\$relation_name FROM rdb\$relations WHERE rdb\$relation_name NOT LIKE 'RDB\$%'"; $res = $this->query($sql); } + + /** + * Return the number of rows affected by the previous query + * + * @return int + */ + function affected_rows() + { + // TODO: Implement + } + + /** + * Return the number of rows returned for a SELECT query + * + * @return int + */ + function num_rows() + { + // TODO: Implement + } } diff --git a/src/databases/mysql.php b/src/databases/mysql.php index ac1e134..b86c4ba 100644 --- a/src/databases/mysql.php +++ b/src/databases/mysql.php @@ -69,6 +69,26 @@ class MySQL extends DB_PDO { return $res->fetchAll(PDO::FETCH_ASSOC); } + /** + * Return the number of rows affected by the previous query + * + * @return int + */ + function affected_rows() + { + // TODO: Implement + } + + /** + * Return the number of rows returned for a SELECT query + * + * @return int + */ + function num_rows() + { + // TODO: Implement + } + } class MySQL_manip extends MySQL { diff --git a/src/databases/odbc.php b/src/databases/odbc.php index 17c4a03..3a2bdf7 100644 --- a/src/databases/odbc.php +++ b/src/databases/odbc.php @@ -48,6 +48,26 @@ class ODBC extends DB_PDO { $this->query($sql); } + /** + * Return the number of rows affected by the previous query + * + * @return int + */ + function affected_rows() + { + // TODO: Implement + } + + /** + * Return the number of rows returned for a SELECT query + * + * @return int + */ + function num_rows() + { + // TODO: Implement + } + } // End of odbc.php \ No newline at end of file diff --git a/src/databases/pgsql.php b/src/databases/pgsql.php index eda0835..313bc78 100644 --- a/src/databases/pgsql.php +++ b/src/databases/pgsql.php @@ -93,6 +93,26 @@ class pgSQL extends DB_PDO { return $views; } + /** + * Return the number of rows affected by the previous query + * + * @return int + */ + function affected_rows() + { + // TODO: Implement + } + + /** + * Return the number of rows returned for a SELECT query + * + * @return int + */ + function num_rows() + { + // TODO: Implement + } + } /** diff --git a/src/databases/sqlite.php b/src/databases/sqlite.php index 525b4b7..dbbd4d3 100644 --- a/src/databases/sqlite.php +++ b/src/databases/sqlite.php @@ -50,7 +50,28 @@ class SQLite extends DB_PDO { */ function get_tables() { - //TODO: implement + $res = $this->query("SELECT name FROM sqlite_master WHERE type='table'"); + return $res->fetchAll(PDO::FETCH_ASSOC); + } + + /** + * Return the number of rows affected by the previous query + * + * @return int + */ + function affected_rows() + { + // TODO: Implement + } + + /** + * Return the number of rows returned for a SELECT query + * + * @return int + */ + function num_rows() + { + // TODO: Implement } }