diff --git a/classes/db_pdo.php b/classes/db_pdo.php index 2e048ce..78c22d9 100644 --- a/classes/db_pdo.php +++ b/classes/db_pdo.php @@ -211,15 +211,35 @@ abstract class DB_PDO extends PDO { return array_map(array($this, 'quote_ident'), $ident); } - // Remove existing escape characters - $ident = str_replace($this->escape_char, '', $ident); + // If the string is already quoted, return the string + if (($pos = strpos($ident, $this->escape_char)) !== FALSE && $pos === 0) + { + return $ident; + } // Split each identifier by the period $hiers = explode('.', $ident); - return $this->escape_char . - implode("{$this->escape_char}.{$this->escape_char}", $hiers) . - $this->escape_char; + // Return the re-compiled string + return implode('.', array_map(array($this, '_quote'), $hiers)); + } + + // -------------------------------------------------------------------------- + + /** + * Helper method for quote_ident + * + * @param mixed $str + * @return mixed + */ + protected function _quote($str) + { + if ( ! is_string($str) && is_numeric($str)) + { + return $str; + } + + return "{$this->escape_char}{$str}{$this->escape_char}"; } // ------------------------------------------------------------------------- diff --git a/classes/query_builder.php b/classes/query_builder.php index 776dc31..abd745a 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -428,7 +428,7 @@ class Query_Builder { $this->query_map[] = array( 'type' => 'like', - 'conjunction' => (empty($this->query_map)) ? 'WHERE ' : " {$conj} ", + 'conjunction' => (empty($this->query_map)) ? ' WHERE ' : " {$conj} ", 'string' => $l ); @@ -1204,6 +1204,8 @@ class Query_Builder { /** * Clear out the class variables, so the next query can be run + * + * @return void */ private function _reset() { @@ -1336,7 +1338,7 @@ class Query_Builder { break; } - //echo $sql . '
'; + echo $sql . '
'; return $sql; } diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 3d6bb90..9a13f0e 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -113,6 +113,7 @@ the connection/database
get_system_tables()
  • Connect to a different database
    switch_db()
  • Empty the passed table
    truncate()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -610,6 +611,21 @@ the connection/database +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    +
    +

    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -662,7 +678,7 @@ the connection/database
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/DB_Reg.html b/docs/classes/DB_Reg.html index a489a53..8ef392c 100644 --- a/docs/classes/DB_Reg.html +++ b/docs/classes/DB_Reg.html @@ -151,7 +151,7 @@ and organizes database connections

    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index aab7100..8f600cf 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -268,7 +268,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index ed09e2e..b212d9b 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -208,7 +208,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 567c09c..0e6d5e7 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -105,6 +105,7 @@ the connection/database
    get_system_tables()
  • Doesn't apply to Firebird
    switch_db()
  • Empty a database table
    truncate()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -719,6 +720,25 @@ the connection/database +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::_quote()
    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -812,7 +832,7 @@ the last query executed
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 9200f61..dcf50ce 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -503,7 +503,7 @@ the query
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 256459c..d2b23b7 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -296,7 +296,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index 497220d..560601c 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -211,7 +211,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index f1eca23..2fb64c3 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -113,6 +113,7 @@ the connection/database
    get_system_tables()
  • Connect to a different database
    switch_db()
  • Empty a table
    truncate()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -774,6 +775,25 @@ the connection/database +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::_quote()
    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -848,7 +868,7 @@ the connection/database
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index e704d0e..4bfeca4 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -280,7 +280,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index 8222cc9..2df4ad0 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -207,7 +207,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index bb3649d..b27bfda 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -113,6 +113,7 @@ the connection/database
    get_system_tables()
  • Doesn't apply to ODBC
    switch_db()
  • Empty the current database
    truncate()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -776,6 +777,25 @@ the connection/database +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::_quote()
    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -850,7 +870,7 @@ the connection/database
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index d0e24de..3de8284 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -280,7 +280,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index b05e146..d90cd2d 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -202,7 +202,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index 6af19dc..cdcd8db 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -113,6 +113,7 @@ the connection/database
    get_system_tables()
  • Connect to a different database
    switch_db()
  • Empty a table
    truncate()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -770,6 +771,25 @@ the connection/database +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::_quote()
    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -850,7 +870,7 @@ the connection/database
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index afd51a5..c2be711 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -296,7 +296,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index f6a99ee..e124d16 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -207,7 +207,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index 8d48dba..eab9d1b 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -1017,7 +1017,7 @@ passed array with key / value pairs

    Clear out the class variables, so the next query can be run

    -
    _reset() 
    +
    _reset() : void

    @@ -1221,7 +1221,7 @@ for complex select queries
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index a3ab83f..2d61922 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -113,6 +113,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()Empty a table
    truncate()
  • Unload a database from the current connection
    unload_database()
  • +
  • Helper method for quote_ident
    _quote()
  • Method to simplify retreiving db results for meta-data queries
    driver_query()
  • @@ -791,6 +792,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Helper method for quote_ident

    +
    _quote(mixed $str) : mixed
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::_quote()
    +

    Parameters

    +
    +

    $str

    +mixed +
    +

    Returns

    +
    mixed
    +
    +

    Method to simplify retreiving db results for meta-data queries

    driver_query(string $sql, bool $filtered_index) : mixed
    @@ -865,7 +885,7 @@ method if the database does not support 'TRUNCATE';
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index a80f168..247a4b4 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -280,7 +280,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index cfd3c4b..815414e 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -207,7 +207,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/classes/Settings.html b/docs/classes/Settings.html index 7d7e82c..798728b 100644 --- a/docs/classes/Settings.html +++ b/docs/classes/Settings.html @@ -243,7 +243,7 @@ directly - the settings should be safe!
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/deprecated.html b/docs/deprecated.html index 34eb10d..7104a71 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -66,7 +66,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/errors.html b/docs/errors.html index f967f08..071d04a 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -92,7 +92,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/graph_class.html b/docs/graph_class.html index de66ec0..2f6cd2f 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -63,7 +63,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/markers.html b/docs/markers.html index 9ddeb0e..0ab7fa7 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -68,7 +68,7 @@
    + generated on 2012-05-01T14:03:17-04:00.
    diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 51faf27..e3950d4 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -282,7 +282,7 @@ instantiates the specific db driver

    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/.html b/docs/packages/.html index 7149853..2ec6382 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -66,7 +66,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/Default.html b/docs/packages/Default.html index 5f6a1b5..140bace 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -93,7 +93,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index 66810fa..1bb5ad3 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -210,7 +210,7 @@ data-fetching methods

    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/Query.Helper Classes.html b/docs/packages/Query.Helper Classes.html index 7b8b6a5..2264685 100644 --- a/docs/packages/Query.Helper Classes.html +++ b/docs/packages/Query.Helper Classes.html @@ -96,7 +96,7 @@
    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index 8685f36..b910e6c 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -114,7 +114,7 @@ instantiates the specific db driver

    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/packages/Query.html b/docs/packages/Query.html index 5a7101e..0407615 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -315,7 +315,7 @@ instantiates the specific db driver

    + generated on 2012-05-01T14:03:16-04:00.
    diff --git a/docs/structure.xml b/docs/structure.xml index 8a1a61b..57546f1 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -510,7 +510,7 @@ directly - the settings should be safe!]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -736,197 +736,216 @@ directly - the settings should be safe!]]> - - empty_table + + _quote function - - + + - - string + + mixed - + mixed - + + $str + + + + + + empty_table + function + + + + + string + + + mixed + + + $table - + get_schemas function - + - + array - + get_tables function - + - + array - + get_dbs function - + - + array - + get_views function - + - + array - + get_sequences function - + - + array - + get_functions function - + - + array - + get_procedures function - + - + array - + get_triggers function - + - + array - + get_system_tables 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 @@ -934,7 +953,7 @@ the connection/database]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -2277,36 +2296,39 @@ in place of the get() method]]> - + _reset function + + void + - + _compile function - + - + string - + string - + \$string - + $type - + $table diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 977faa7..0126025 100644 Binary files a/tests/db_files/FB_TEST_DB.FDB and b/tests/db_files/FB_TEST_DB.FDB differ