diff --git a/classes/db_pdo.php b/classes/db_pdo.php index 78c22d9..53bfc5a 100644 --- a/classes/db_pdo.php +++ b/classes/db_pdo.php @@ -366,6 +366,31 @@ abstract class DB_PDO extends PDO { { return $this->driver_query($this->sql->system_table_list()); } + + // -------------------------------------------------------------------------- + + /** + * Retrieve column information for the current database table + * + * @param string $table + * @return array + */ + public function get_columns($table) + { + return $this->driver_query($this->sql->column_list($table), FALSE); + } + + // -------------------------------------------------------------------------- + + /** + * Retrieve list of data types for the database + * + * @return array + */ + public function get_types() + { + return $this->driver_query($this->sql->type_list(), FALSE); + } // ------------------------------------------------------------------------- @@ -378,10 +403,17 @@ abstract class DB_PDO extends PDO { */ protected function driver_query($sql, $filtered_index=TRUE) { + // Return if the query doesn't apply to the driver if ($sql === FALSE) { return FALSE; } + + // Return predefined data + if (is_array($sql)) + { + return $sql; + } $res = $this->query($sql); diff --git a/classes/db_sql.php b/classes/db_sql.php index 46559ed..016b530 100644 --- a/classes/db_sql.php +++ b/classes/db_sql.php @@ -168,5 +168,14 @@ abstract class DB_SQL { * @return mixed */ abstract public function type_list(); + + /** + * Get information about the columns in the + * specified table + * + * @param string + * @return string + */ + abstract public function column_list($table); } // End of db_sql.php \ No newline at end of file diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 95f2409..a85825c 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -35,7 +35,7 @@ 0
empty_table()getAttribute()
getAvailableDrivers()
get_columns()
get_dbs()
get_functions()
get_last_error()
get_system_tables()
get_tables()
get_triggers()
get_types()
get_views()
inTransaction()
get_columns(string $table) : array+ +
string
+array
get_dbs() : array@@ -422,6 +439,16 @@ the connection/database
array
get_types() : array+ +
array
get_views() : array@@ -680,7 +707,7 @@ the connection/database + generated on 2012-05-09T13:54:12-04:00.