From 3da9cd9c19e9a6eaf8ed0f52dd8e96e6f12fdb7e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 9 May 2012 13:54:38 -0400 Subject: [PATCH] Added more meta-information methods, with tests --- classes/db_pdo.php | 32 +++ classes/db_sql.php | 9 + docs/classes/DB_PDO.html | 31 ++- docs/classes/DB_Reg.html | 4 +- docs/classes/DB_SQL.html | 22 +- docs/classes/DB_Util.html | 4 +- docs/classes/Firebird.html | 39 +++- docs/classes/Firebird_Result.html | 4 +- docs/classes/Firebird_SQL.html | 4 +- docs/classes/Firebird_Util.html | 4 +- docs/classes/MySQL.html | 39 +++- docs/classes/MySQL_SQL.html | 27 ++- docs/classes/MySQL_Util.html | 4 +- docs/classes/ODBC.html | 39 +++- docs/classes/ODBC_SQL.html | 20 +- docs/classes/ODBC_Util.html | 4 +- docs/classes/PgSQL.html | 39 +++- docs/classes/PgSQL_SQL.html | 4 +- docs/classes/PgSQL_Util.html | 4 +- docs/classes/Query_Builder.html | 18 +- docs/classes/SQLite.html | 39 +++- docs/classes/SQLite_SQL.html | 20 +- docs/classes/SQLite_Util.html | 4 +- docs/classes/Settings.html | 4 +- docs/deprecated.html | 4 +- docs/errors.html | 4 +- docs/graph_class.html | 4 +- docs/markers.html | 26 +-- docs/namespaces/default.html | 4 +- docs/packages/.html | 4 +- docs/packages/Default.html | 4 +- docs/packages/Query.Drivers.html | 4 +- docs/packages/Query.Helper Classes.html | 4 +- docs/packages/Query.Query.html | 4 +- docs/packages/Query.html | 4 +- docs/structure.xml | 298 ++++++++++++++++-------- drivers/mysql/mysql_sql.php | 22 +- drivers/mysql/mysql_util.php | 14 ++ drivers/odbc/odbc_sql.php | 14 ++ drivers/sqlite/sqlite_sql.php | 13 ++ tests/core/db_test.php | 16 ++ tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 42 files changed, 671 insertions(+), 190 deletions(-) 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
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -81,6 +81,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -93,6 +94,7 @@ the connection/database">Retreives an array of non-use the connection/database
    get_system_tables()
  • Return list of tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -316,6 +318,21 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -422,6 +439,16 @@ the connection/database
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    +
    +

    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -680,7 +707,7 @@ the connection/database
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/DB_Reg.html b/docs/classes/DB_Reg.html index 33f8e66..5c18593 100644 --- a/docs/classes/DB_Reg.html +++ b/docs/classes/DB_Reg.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -153,7 +153,7 @@ and organizes database connections

    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index ae0dbc7..7cf309a 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -59,6 +59,9 @@
  • Get the 'average' keyword
    avg()
  • +
  • Get information about the columns in the +specified table
    column_list()
  • Returns sql to list other databases
    db_list()
  • Get the 'distinct' keyword
    distinct()
  • Return sql to list functions
    function_list()
  • @@ -103,6 +106,21 @@
    string
    +
    +

    Get information about the columns in the +specified table

    +
    column_list($table) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +

    string

    +

    Returns

    +
    string
    +
    +

    Returns sql to list other databases

    db_list() : string
    @@ -281,7 +299,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index 60ba07e..1ce2204 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -210,7 +210,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 98642a5..1c26386 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -77,6 +77,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -89,6 +90,7 @@ the connection/database">Retreives an array of non-use the connection/database
    get_system_tables()
  • Return list of tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -335,6 +337,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_columns()
    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -481,6 +502,20 @@ the connection/database
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_types()
    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -834,7 +869,7 @@ the last query executed
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 8297b80..3d48904 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -505,7 +505,7 @@ the query
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 0a56b77..56cdace 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -309,7 +309,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index a7cd629..ad6b7e4 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -213,7 +213,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index 3ddbc12..c1143ec 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -81,6 +81,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -93,6 +94,7 @@ the connection/database">Retreives an array of non-use the connection/database
    get_system_tables()
  • Return list of tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -378,6 +380,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_columns()
    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -524,6 +545,20 @@ the connection/database
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_types()
    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -870,7 +905,7 @@ the connection/database
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index 4a17b02..c254316 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -59,6 +59,7 @@
  • Get the 'average' keyword
    avg()
  • +
  • SQL to show infromation about columns in a table
    column_list()
  • Returns sql to list other databases
    db_list()
  • Get the 'distinct' keyword
    distinct()
  • Return sql to list functions
    function_list()
  • @@ -107,6 +108,21 @@
    string
    +
    +

    SQL to show infromation about columns in a table

    +
    column_list(string $table) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    string
    +
    +

    Returns sql to list other databases

    db_list() : string
    @@ -248,10 +264,15 @@

    Returns sql to list tables

    -
    table_list() : string
    +
    table_list(string $database) : string

    +

    Parameters

    +
    +

    $database

    +string +

    Returns

    string
    @@ -293,7 +314,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index 8f5b3a9..f436d53 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -209,7 +209,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index f7a50dc..ee6408d 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -81,6 +81,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -93,6 +94,7 @@ the connection/database">Retreives an array of non-use the connection/database
    get_system_tables()
  • Return list of tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -378,6 +380,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_columns()
    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -524,6 +545,20 @@ the connection/database
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_types()
    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -872,7 +907,7 @@ the connection/database
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index 189c2fa..144a299 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -59,6 +59,7 @@
  • Get the 'average' keyword
    avg()
  • +
  • SQL to show infromation about columns in a table
    column_list()
  • Returns sql to list other databases
    db_list()
  • Get the 'distinct' keyword
    distinct()
  • Return sql to list functions
    function_list()
  • @@ -107,6 +108,21 @@
    string
    +
    +

    SQL to show infromation about columns in a table

    +
    column_list(string $table) : FALSE
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    FALSE
    +
    +

    Returns sql to list other databases

    db_list() : FALSE
    @@ -293,7 +309,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index ff9f659..5e1074b 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -204,7 +204,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index c56cb8c..37a8c4e 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -81,6 +81,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -93,6 +94,7 @@ the connection/database">Retreives an array of non-use the connection/database
    get_system_tables()
  • Return list of tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -378,6 +380,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_columns()
    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -520,6 +541,20 @@ the connection/database
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_types()
    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -872,7 +907,7 @@ the connection/database
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index 5b758b0..622c265 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -309,7 +309,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index 3e06fbe..b3f6370 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -209,7 +209,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index c6a4c58..f2f8590 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -119,6 +119,7 @@ passed array with key / value pairs
    where()
  • Convenience property for connection management
    $conn_name
  • +
  • Alias to $this->db->sql
    $sql
  • Compiled 'from' clause
    $from_string
  • Key/val pairs for group by clause
    $group_array
  • @@ -134,7 +135,6 @@ for complex select queries
    $query_map
  • Compiled 'select' clause
    $select_string
  • Keys for insert/update statement
    $set_array_keys
  • Compiled arguments for insert / update
    $set_string
  • -
  • Alias to $this->db->sql
    $sql
  • Values to apply to prepared statements
    $values
  • @@ -1125,6 +1125,12 @@ passed array with key / value pairs

    + 
    +

    Alias to $this->db->sql

    +
    $sql : \DB_PDO
    +
    +

    +
     

    Compiled 'from' clause

    $from_string : string
    @@ -1204,12 +1210,6 @@ for complex select queries

    - 
    -

    Alias to $this->db->sql

    -
    $sql : \DB_PDO
    -
    -

    -
     

    Values to apply to prepared statements

    $values : array
    @@ -1223,7 +1223,7 @@ for complex select queries
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index 9d68dc7..18d70c5 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -81,6 +81,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()
    getAttribute()
  • getAvailableDrivers()
    getAvailableDrivers()
  • +
  • Retrieve column information for the current database table
    get_columns()
  • Return list of dbs for the current connection, if possible
    get_dbs()
  • Return list of function for the current database
    get_functions()
  • Return the last error for the current database connection
    get_last_error()
  • @@ -91,6 +92,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()List system tables for the current database
    get_system_tables()
  • List tables for the current database
    get_tables()
  • Return list of triggers for the current database
    get_triggers()
  • +
  • Retrieve list of data types for the database
    get_types()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • @@ -374,6 +376,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Retrieve column information for the current database table

    +
    get_columns(string $table) : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_columns()
    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    array
    +
    +

    Return list of dbs for the current connection, if possible

    get_dbs() : array
    @@ -511,6 +532,20 @@ method if the database does not support 'TRUNCATE';
    array
    +
    +

    Retrieve list of data types for the database

    +
    get_types() : array
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::get_types()
    +

    Returns

    +
    array
    +
    +

    Return list of views for the current database

    get_views() : array
    @@ -887,7 +922,7 @@ method if the database does not support 'TRUNCATE';
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index f4c4938..a806f24 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -59,6 +59,7 @@
  • Get the 'average' keyword
    avg()
  • +
  • SQL to show infromation about columns in a table
    column_list()
  • Returns sql to list other databases
    db_list()
  • Get the 'distinct' keyword
    distinct()
  • Return sql to list functions
    function_list()
  • @@ -107,6 +108,21 @@
    string
    +
    +

    SQL to show infromation about columns in a table

    +
    column_list(string $table) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +

    Returns

    +
    string
    +
    +

    Returns sql to list other databases

    db_list() : FALSE
    @@ -293,7 +309,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index 96f70ee..84aafe0 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -209,7 +209,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/classes/Settings.html b/docs/classes/Settings.html index da09ef5..1f23a33 100644 --- a/docs/classes/Settings.html +++ b/docs/classes/Settings.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -245,7 +245,7 @@ directly - the settings should be safe!
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/deprecated.html b/docs/deprecated.html index cfbb15b..572a839 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -68,7 +68,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/errors.html b/docs/errors.html index 80ed901..84c9146 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -94,7 +94,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/graph_class.html b/docs/graph_class.html index e6044c2..2970b0a 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -65,7 +65,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/markers.html b/docs/markers.html index 22a4b84..2f122fe 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -58,7 +58,6 @@
  • drivers/pgsql/pgsql_driver.php
  • drivers/mysql/mysql_util.php
  • drivers/mysql/mysql_driver.php
  • -
  • drivers/mysql/mysql_sql.php
  • drivers/firebird/firebird_util.php
  • @@ -71,7 +70,7 @@
    The following markers were found:
    • todo  - 7 + 6
    @@ -138,7 +137,7 @@ todo -127 +141 Implement Backup function
    @@ -161,23 +160,6 @@
    -

    -drivers/mysql/mysql_sql.php1 -

    -
    - - - - - - - - - - -
    TypeLineDescription
    todo160implement type_list method
    -
    -

    drivers/firebird/firebird_util.php1

    @@ -200,7 +182,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 5a8a6a0..27bf0c0 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -284,7 +284,7 @@ instantiates the specific db driver

    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/.html b/docs/packages/.html index 9de2078..d906878 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -68,7 +68,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/Default.html b/docs/packages/Default.html index 14969bb..4c5857a 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -95,7 +95,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index 3f0eabe..a9a1548 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -212,7 +212,7 @@ data-fetching methods

    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/Query.Helper Classes.html b/docs/packages/Query.Helper Classes.html index 5b28859..f501d29 100644 --- a/docs/packages/Query.Helper Classes.html +++ b/docs/packages/Query.Helper Classes.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -98,7 +98,7 @@
    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index b5f5f88..89785e7 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -116,7 +116,7 @@ instantiates the specific db driver

    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/packages/Query.html b/docs/packages/Query.html index 36159e5..06ea3b1 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -35,7 +35,7 @@ 0
  •  Markers 
    • todo  - 7 + 6
  •  Deprecated elements  0
  • @@ -317,7 +317,7 @@ instantiates the specific db driver

    + generated on 2012-05-09T13:54:12-04:00.
    diff --git a/docs/structure.xml b/docs/structure.xml index bdbc5ae..1c5c9c5 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -297,7 +297,7 @@ directly - the settings should be safe!]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -519,9 +519,27 @@ directly - the settings should be safe!]]>
    + + column_list + function + + + + + + string + + + + $table + + + +
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -886,77 +904,107 @@ the connection/database]]>
    - - driver_query + + get_columns function - + - + string - - bool - - - mixed + + array - - $sql - - - - - $filtered_index - - - - - - num_rows - function - - - - - int - - - - - truncate - function - - - - - string - - - void - - - + $table - - switch_db + + get_types function - - + + - + + array + + + + + driver_query + function + + + + string - + + bool + + + mixed + + + + $sql + + + + + $filtered_index + + + + + + num_rows + function + + + + + int + + + + + truncate + function + + + + + string + + void - + + $table + + + + + + switch_db + function + + + + + string + + + void + + + $name @@ -964,7 +1012,7 @@ the connection/database]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -1109,7 +1157,7 @@ instantiates the specific db driver]]>
    - + $sql @@ -2582,7 +2630,7 @@ with array_map and glob]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -3136,7 +3184,7 @@ with array_map and glob]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -3301,6 +3349,25 @@ with array_map and glob]]>
    + + column_list + function + + + + + string + + + FALSE + + + + $table + + + +
    @@ -3411,7 +3478,7 @@ with array_map and glob]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -3422,7 +3489,7 @@ with array_map and glob]]>
    - Implement Backup function + Implement Backup function MySQL_Util @@ -3526,20 +3593,20 @@ with array_map and glob]]> - + backup_data function - + - + array - + string - + $exclude @@ -3655,7 +3722,7 @@ with array_map and glob]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -3665,9 +3732,6 @@ with array_map and glob]]>
    - - implement type_list method - MySQL_SQL \MySQL_SQL @@ -3735,94 +3799,121 @@ with array_map and glob]]> - + table_list function + + string + string + + $database + + + - + system_table_list function - + - + string - + view_list function - + - + string - + trigger_list function - + - + string - + function_list function - + - + string - + procedure_list function - + - + string - + sequence_list function - + - + FALSE - + type_list function - + - + string + + column_list + function + + + + + string + + + string + + + + $table + + + +
    @@ -4117,7 +4208,7 @@ with array_map and glob]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -4282,9 +4373,28 @@ with array_map and glob]]>
    + + column_list + function + + + + + string + + + string + + + + $table + + + +
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -5314,7 +5424,7 @@ the last query executed]]> - todo + todo fixme diff --git a/drivers/mysql/mysql_sql.php b/drivers/mysql/mysql_sql.php index 9d0ad04..db60c1b 100644 --- a/drivers/mysql/mysql_sql.php +++ b/drivers/mysql/mysql_sql.php @@ -68,10 +68,15 @@ class MySQL_SQL extends DB_SQL { /** * Returns sql to list tables * + * @param string $database * @return string */ - public function table_list() + public function table_list($database='') { + if ( ! empty($database)) + { + return "SHOW TABLES FROM `{$database}`"; + } return 'SHOW TABLES'; } @@ -157,7 +162,20 @@ class MySQL_SQL extends DB_SQL { */ public function type_list() { - // TODO implement type_list method + return "SELECT DISTINCT `DATA_TYPE` FROM `information_schema`.`COLUMNS`"; + } + + // -------------------------------------------------------------------------- + + /** + * SQL to show infromation about columns in a table + * + * @param string $table + * @return string + */ + public function column_list($table) + { + return "SHOW FULL COLUMNS FROM {$table}"; } } //End of mysql_sql.php \ No newline at end of file diff --git a/drivers/mysql/mysql_util.php b/drivers/mysql/mysql_util.php index a6f36b1..e72be2d 100644 --- a/drivers/mysql/mysql_util.php +++ b/drivers/mysql/mysql_util.php @@ -124,6 +124,20 @@ class MySQL_Util extends DB_Util { */ public function backup_structure() { + $sql = ''; + + // Get databases + $dbs = $this->conn->get_dbs(); + + foreach($dbs as $d) + { + // Get the list of tables + + // Get the sql for the table + $query = $this->conn->query("SHOW CREATE TABLE {$table}"); + + } + // TODO Implement Backup function return ''; } diff --git a/drivers/odbc/odbc_sql.php b/drivers/odbc/odbc_sql.php index 9c451f3..09fa01f 100644 --- a/drivers/odbc/odbc_sql.php +++ b/drivers/odbc/odbc_sql.php @@ -153,5 +153,19 @@ class ODBC_SQL extends DB_SQL { { return FALSE; } + + // -------------------------------------------------------------------------- + + /** + * SQL to show infromation about columns in a table + * + * @param string $table + * @return FALSE + */ + public function column_list($table) + { + return FALSE; + } + } // End of odbc_sql.php \ No newline at end of file diff --git a/drivers/sqlite/sqlite_sql.php b/drivers/sqlite/sqlite_sql.php index fd443ed..5c1d8da 100644 --- a/drivers/sqlite/sqlite_sql.php +++ b/drivers/sqlite/sqlite_sql.php @@ -165,6 +165,19 @@ SQL; { return array('INTEGER', 'REAL', 'TEXT', 'BLOB'); } + + // -------------------------------------------------------------------------- + + /** + * SQL to show infromation about columns in a table + * + * @param string $table + * @return string + */ + public function column_list($table) + { + return 'PRAGMA table_info("'.$table.'")'; + } } //End of sqlite_sql.php \ No newline at end of file diff --git a/tests/core/db_test.php b/tests/core/db_test.php index 6aa12b3..7c4849e 100644 --- a/tests/core/db_test.php +++ b/tests/core/db_test.php @@ -64,5 +64,21 @@ abstract class DBTest extends UnitTestCase { { $this->assertTrue(is_string($this->db->util->backup_data())); } + + // -------------------------------------------------------------------------- + + public function TestGetColumns() + { + $cols = $this->db->get_columns('create_test'); + $this->assertTrue(is_array($cols)); + } + + // -------------------------------------------------------------------------- + + public function TestGetTypes() + { + $types = $this->db->get_types(); + $this->assertTrue(is_array($types)); + } } // End of db_test.php \ No newline at end of file diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 2953a58016cc87a824bb5207a648a96708de8d86..d4195a1c8752ee1d9554fbf48901687525ae4820 100644 GIT binary patch delta 1443 zcmb7^O=uHA6oB7sk~YmtnyDfNjb%68q-(X>Xll`ug14e5)`GpX#cDm21X`geh(Tlz zo{ApkARc=2B8WfDNkQ_!BxlD0I7Byq!5)7G7#jG{y`EAVI2d$|`2wS-W4*M-UL@~vmot|e zE)Tgp?DB}qTU_4i@~F$(7I-Yo+2KmWj9rdCI?W@M5hpg^>h{GJ`Y`-_G~A|a>*p}r z4WBRzPum@E+OuFMOqfcV0ErAtBogo?-UYAX4t#9yf+3Rc(>zDtZp5>2mSj1cWCq@2 z0{&o5+-=|39c=?Z%rs~ow#A)A9Ar81tB#gfT||Cqk~UIK zl%i)qzF?Etw*y|z)|w;gM<`7IMCqov z6oq1`*gIRAo``#7mC!}dbiknE&iu6r`NINBI z=XK`6Y)Rw#u*KMf|K|OpL7IsY>A+&V@Q;>&pYJ%ErL)NkpxNN0`$LFh}pyEtYuj z9ee1VI>i==Wy*4oY?n?kTEpxaZA%>q?*CS#Z51vsz0QL#x>@uNdy{Y5_dP&o-juj X52V#^Mo?`Sj(VV)u(JLGjSGJPg$e{Z delta 1593 zcmbVML1+^}6#cu|O*Z+q9ovc#Q8!J~)>0wC6sZ>xg@OeYtkqkq*js5JB7!Il9`>fv z(;#|K@uDC~we3w2>P197dyqzKBSn)6MXGd*e`a=)g0`T4nVtQ!Gw;87|IZW(nL;6R z)PSD!U<=fYVIdTFqHj(BY^4TZ8n-?G^zVDu{xhy7Ffi#El8!;|=ET#)&_u&k<}t%# zrpH1avpi;dEbOs}#~hDEr&!ElMts_KV<(;I!H(G7$oP=$rDIcRw4MwuItp692aG0| z38$bx+5t{91$Uw?(CoM{6Ln!R(gOWX9bAqk;Y}n7_ahxpp#Ct8rD^PRBn4Ue7WOP$ z2VcW&{6-n$CRluK7W<4a&lE9p;%rWkH>s&UleK8W&&4ttF@S;gL(=cfYu}VUO$+AN zOWz&`Sl*XlgxS z35v=DDHs`kB`|8OdkqFr<2Ng~g};H}NzX>a@`me=Vae3PUCdd9k8Udm0f2FBmkTfJO zzg@w`u9y#Nux+vBb+jVd56hUOqIp}!HgnbGA1k=ylu3E1+Io^{34~xmGVQDS>dkAv zA&_j@<<~3dc5U)O6hdH<9jPV~9%Pbwl}TD5*vV9yzXEO+EftfcNp7wh2x{Fo32m9i zMEYbcQ~I?pxl(lPE3V!ClH$fMm9Wz!hr%8)f2fFj*EdYS}LN&hv(33CFa^>>61P};Goet?Y1mQ zst09Z>5D=~*NZnOH2z{1Tg4Sc`{`pEK;Jz4Jsnu8!S5wZ?1d`ZU^g0`k}2+*znopE ak`?hm9rt8)#Rf}+$QG5NJH1*#^Z0LMXan2;