From f6bfe414e66bcf897fc07cb5bc3d2a78dfbc5d9f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 3 May 2013 13:07:34 -0400 Subject: [PATCH] Add insert batch as a function to overwrite in drivers --- classes/db_pdo.php | 39 +++ classes/query_builder.php | 39 ++- docs/classes/BadConnectionException.html | 2 +- docs/classes/BadDBDriverException.html | 2 +- docs/classes/DB_PDO.html | 22 +- docs/classes/DB_Util.html | 2 +- docs/classes/Firebird.html | 22 +- docs/classes/Firebird_Result.html | 2 +- docs/classes/Firebird_SQL.html | 2 +- docs/classes/Firebird_Util.html | 2 +- docs/classes/MySQL.html | 26 +- docs/classes/MySQL_SQL.html | 2 +- docs/classes/MySQL_Util.html | 2 +- docs/classes/ODBC.html | 22 +- docs/classes/ODBC_SQL.html | 2 +- docs/classes/ODBC_Util.html | 2 +- docs/classes/PgSQL.html | 26 +- docs/classes/PgSQL_SQL.html | 2 +- docs/classes/PgSQL_Util.html | 2 +- docs/classes/Query_Builder.html | 32 ++- docs/classes/Query_Parser.html | 2 +- docs/classes/SQLite.html | 22 +- docs/classes/SQLite_SQL.html | 2 +- docs/classes/SQLite_Util.html | 2 +- docs/classes/iDB_SQL.html | 2 +- docs/classes/iQuery_Builder.html | 2 +- docs/deprecated.html | 2 +- docs/errors.html | 2 +- docs/graph_class.html | 2 +- docs/markers.html | 2 +- docs/namespaces/default.html | 2 +- docs/packages/.html | 2 +- docs/packages/Default.html | 2 +- docs/packages/Query.Drivers.html | 2 +- docs/packages/Query.Query.html | 2 +- docs/packages/Query.html | 2 +- docs/structure.xml | 317 +++++++++++++++++------ drivers/firebird/firebird_driver.php | 15 ++ drivers/odbc/odbc_driver.php | 15 ++ drivers/sqlite/sqlite_driver.php | 15 ++ tests/core/db_qb_test.php | 29 +++ tests/databases/firebird/firebird-qb.php | 2 + tests/databases/sqlite/sqlite-qb.php | 29 +++ tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 44 files changed, 604 insertions(+), 122 deletions(-) diff --git a/classes/db_pdo.php b/classes/db_pdo.php index f8a1aaa..037419a 100644 --- a/classes/db_pdo.php +++ b/classes/db_pdo.php @@ -538,5 +538,44 @@ abstract class DB_PDO extends PDO { * @return void */ abstract public function truncate($table); + + // -------------------------------------------------------------------------- + + /** + * Create sql for batch insert + * + * @param string $table + * @param array $data + * @return string + */ + public function insert_batch($table, $data=array()) + { + if ( ! is_array($data[0])) return NULL; + + $table = $this->quote_table($table); + $fields = array_keys($data[0]); + $vals = array(); + + $sql = "INSERT INTO {$table} ("; + $sql .= implode(',', $this->quote_ident($fields)); + $sql .= ") VALUES "; + + $params = array_fill(0, count($fields), '?'); + $param_string = implode(',', $params); + + // Remove the first array after use, as it is a special case + $sql .= "({$param_string})"; + $vals = array_values($data[0]); + array_shift($data); + + // Add another grouping for each + foreach($data as $group) + { + $sql .= ",({$param_string})"; + $vals = array_merge($vals, array_values($group)); + } + + return array($sql, $vals); + } } // End of db_pdo.php \ No newline at end of file diff --git a/classes/query_builder.php b/classes/query_builder.php index 735d0da..ee352fc 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -1016,6 +1016,28 @@ class Query_Builder implements iQuery_Builder { return $this->_run("insert", $table); } + + // -------------------------------------------------------------------------- + + /** + * Create sql for batch insert + * + * @param string $table + * @param array $data + * @return string + */ + public function insert_batch($table, $data=array()) + { + // Get the generated values and sql string + list($sql, $data) = $this->db->insert_batch($table, $data); + + if ( ! is_null($sql)) + { + return $this->_run('', $table, FALSE, $sql, $data); + } + + return NULL; + } // -------------------------------------------------------------------------- @@ -1185,13 +1207,22 @@ class Query_Builder implements iQuery_Builder { * @param string $type * @param string $table * @param bool $simple + * @param string $sql + * @param mixed $vals * @return mixed */ - protected function _run($type, $table, $simple=FALSE) + protected function _run($type, $table, $simple=FALSE, $sql=NULL, $vals=NULL) { - $sql = $this->_compile($type, $table); - $vals = array_merge($this->values, (array) $this->where_values); - + if (is_null($sql)) + { + $sql = $this->_compile($type, $table); + } + + if (is_null($vals)) + { + $vals = array_merge($this->values, (array) $this->where_values); + } + // Add quotes to 'string' values foreach($vals as &$v) { diff --git a/docs/classes/BadConnectionException.html b/docs/classes/BadConnectionException.html index b7abc69..1fc90b7 100644 --- a/docs/classes/BadConnectionException.html +++ b/docs/classes/BadConnectionException.html @@ -219,7 +219,7 @@
+ generated on 2013-05-03T13:07:08-04:00.
diff --git a/docs/classes/BadDBDriverException.html b/docs/classes/BadDBDriverException.html index 09bae6c..99bdbe1 100644 --- a/docs/classes/BadDBDriverException.html +++ b/docs/classes/BadDBDriverException.html @@ -219,7 +219,7 @@
+ generated on 2013-05-03T13:07:08-04:00.
diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 3d3ea1d..f22b623 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -99,6 +99,7 @@ the connection/database
get_system_tables()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Return the number of rows returned for a SELECT query
    num_rows()
  • @@ -494,6 +495,25 @@ the connection/database +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -743,7 +763,7 @@ the connection/database
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index 1becc56..952a6ac 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -210,7 +210,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 4de197b..95ad9bc 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -95,6 +95,7 @@ the connection/database
    get_system_tables()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Return the number of rows returned for a SELECT query
    num_rows()
  • @@ -575,6 +576,25 @@ the connection/database +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -925,7 +945,7 @@ the last query executed
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 7139097..2265ca8 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -505,7 +505,7 @@ the query
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 5c9c204..1588d8f 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -234,7 +234,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index 777dd4c..bd77804 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -213,7 +213,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index bb95ad8..62ba246 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -99,6 +99,7 @@ the connection/database
    get_system_tables()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Return the number of rows returned for a SELECT query
    num_rows()
  • @@ -618,6 +619,29 @@ the connection/database +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::insert_batch()
    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -963,7 +987,7 @@ the connection/database
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index 9519292..23b9962 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -239,7 +239,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index e5d4d7c..52a563b 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -209,7 +209,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index 6365cad..73369f2 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -99,6 +99,7 @@ the connection/database
    get_system_tables()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Return the number of rows returned for a SELECT query
    num_rows()
  • @@ -618,6 +619,25 @@ the connection/database +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -963,7 +983,7 @@ the connection/database
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index 321297f..ba1a52e 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -234,7 +234,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index d3af245..e5f3b9c 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -204,7 +204,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index 6756a67..21b0e51 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -99,6 +99,7 @@ the connection/database
    get_system_tables()
  • Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Return the number of rows returned for a SELECT query
    num_rows()
  • @@ -614,6 +615,29 @@ the connection/database +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    Inherited
    +
    +

    + + + +
    inherited_from\DB_PDO::insert_batch()
    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -965,7 +989,7 @@ the connection/database
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index f7a759b..f990ea2 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -234,7 +234,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index b81e2c5..78bdd7b 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -209,7 +209,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index 2219a4a..04ac3a3 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -80,6 +80,7 @@ execute current compiled query
    get()
  • Adds a paren to the current query for query grouping
    group_start()
  • Generates a 'Having' clause
    having()
  • Creates an insert clause, and executes it
    insert()
  • +
  • Create sql for batch insert
    insert_batch()
  • Creates a join phrase in a compiled query
    join()
  • Creates a Like clause in the sql statement
    like()
  • Set a limit on the current sql statement
    limit()
  • @@ -499,6 +500,25 @@ execute current compiled query
    mixed
    +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    Creates a join phrase in a compiled query

    join(string $table, string $condition, string $type) : \Query_Builder
    @@ -1135,7 +1155,7 @@ passed array with key / value pairs

    Executes the compiled query

    -
    _run(string $type, string $table, bool $simple) : mixed
    +
    _run(string $type, string $table, bool $simple, string $sql, mixed $vals) : mixed

    @@ -1152,6 +1172,14 @@ passed array with key / value pairs

    $simple

    bool
    +
    +

    $sql

    +string +
    +
    +

    $vals

    +mixed +

    Returns

    mixed
    @@ -1361,7 +1389,7 @@ passed array with key / value pairs
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/Query_Parser.html b/docs/classes/Query_Parser.html index db9a6e5..48769bd 100644 --- a/docs/classes/Query_Parser.html +++ b/docs/classes/Query_Parser.html @@ -145,7 +145,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index 39bc6c7..6f44057 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -97,6 +97,7 @@ method if the database does not support 'TRUNCATE';
    empty_table()Return list of views for the current database
    get_views()
  • inTransaction()
    inTransaction()
  • +
  • Create sql for batch insert
    insert_batch()
  • lastInsertId()
    lastInsertId()
  • Load a database for the current connection
    load_database()
  • @@ -605,6 +606,25 @@ method if the database does not support 'TRUNCATE'; +
    +

    Create sql for batch insert

    +
    insert_batch(string $table, array $data) : string
    +
    +
    +

    +

    Parameters

    +
    +

    $table

    +string +
    +
    +

    $data

    +array +
    +

    Returns

    +
    string
    +
    +

    lastInsertId()

    @@ -980,7 +1000,7 @@ method if the database does not support 'TRUNCATE';
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index 83962d4..9572143 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -234,7 +234,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index 6733ec2..27a4040 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -209,7 +209,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/iDB_SQL.html b/docs/classes/iDB_SQL.html index 505e278..b072dc9 100644 --- a/docs/classes/iDB_SQL.html +++ b/docs/classes/iDB_SQL.html @@ -244,7 +244,7 @@ specified table
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/classes/iQuery_Builder.html b/docs/classes/iQuery_Builder.html index db86fb4..2a8b182 100644 --- a/docs/classes/iQuery_Builder.html +++ b/docs/classes/iQuery_Builder.html @@ -964,7 +964,7 @@ passed array with key / value pairs
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/deprecated.html b/docs/deprecated.html index 7fcbe86..db68b0c 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -68,7 +68,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/errors.html b/docs/errors.html index 82de262..494be8e 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -237,7 +237,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/graph_class.html b/docs/graph_class.html index 7b949bd..96b51e0 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -65,7 +65,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/markers.html b/docs/markers.html index f9463ea..0018d1d 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -110,7 +110,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 90a0784..f0f5cc2 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -340,7 +340,7 @@ instantiates the specific db driver

    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/packages/.html b/docs/packages/.html index 6eeef33..3c74093 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -68,7 +68,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/packages/Default.html b/docs/packages/Default.html index a227b0f..06614fe 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -95,7 +95,7 @@
    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index 9009e42..883fe8f 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -212,7 +212,7 @@ data-fetching methods

    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index 27374c1..df4ec2e 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -150,7 +150,7 @@ instantiates the specific db driver

    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/packages/Query.html b/docs/packages/Query.html index 88fd9ca..37c59ef 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -362,7 +362,7 @@ instantiates the specific db driver

    + generated on 2013-05-03T13:07:08-04:00.
    diff --git a/docs/structure.xml b/docs/structure.xml index bafed20..60defa0 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -98,7 +98,7 @@ - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -577,9 +577,36 @@ the connection/database]]> + + insert_batch + function + + + + + string + + + array + + + string + + + + $table + + + + + $data + + + +
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -1766,19 +1793,19 @@ in place of the get() method]]> - update + insert_batch function - + string - - mixed + + array - - mixed + + string @@ -1792,267 +1819,310 @@ in place of the get() method]]> - - delete + + update function - - + + - + string - + mixed - + mixed - + $table - + + $data + + + + + + delete + function + + + + + string + + + mixed + + + mixed + + + + $table + + + + $where - + get_compiled_select function - + - + string - + bool - + string - + $table - + $reset - + get_compiled_insert function - + - + string - + bool - + string - + $table - + $reset - + get_compiled_update function - + - + string - + bool - + string - + $table - + $reset - + get_compiled_delete function - + - + string - + bool - + string - + $table - + $reset - + _get_compile function - + - + string - + string - - + + - + $type - + $table - + $reset - + reset_query function - + - + void - + _run function - + - + string - + string - + bool - + + string + + + mixed + + mixed - + $type - + $table - + $simple + + $sql + + + + + $vals + + + - + __call function - + - + string - + array - + mixed - + $name - + $params - + _compile function - + - + string - + string - + \$string - + $type - + $table @@ -4324,7 +4394,7 @@ with array_map and glob]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -4411,6 +4481,33 @@ with array_map and glob]]> + + insert_batch + function + + + + + string + + + array + + + string + + + + $table + + + + + $data + + + +
    @@ -4963,7 +5060,7 @@ with array_map and glob]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -5104,6 +5201,33 @@ with array_map and glob]]> + + insert_batch + function + + + + + string + + + array + + + string + + + + $table + + + + + $data + + + +
    @@ -5856,7 +5980,7 @@ the query]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -6151,6 +6275,33 @@ the last query executed]]> + + insert_batch + function + + + + + string + + + array + + + string + + + + $table + + + + + $data + + + +
    diff --git a/drivers/firebird/firebird_driver.php b/drivers/firebird/firebird_driver.php index 42c13f3..d12cdc7 100644 --- a/drivers/firebird/firebird_driver.php +++ b/drivers/firebird/firebird_driver.php @@ -268,5 +268,20 @@ class Firebird extends DB_PDO { // the firebird database return NULL; } + + // -------------------------------------------------------------------------- + + /** + * Create sql for batch insert + * + * @param string $table + * @param array $data + * @return string + */ + public function insert_batch($table, $data=array()) + { + // This is not very applicable to the firebird database + return NULL; + } } // End of firebird_driver.php \ No newline at end of file diff --git a/drivers/odbc/odbc_driver.php b/drivers/odbc/odbc_driver.php index cd96c0a..fabe90f 100644 --- a/drivers/odbc/odbc_driver.php +++ b/drivers/odbc/odbc_driver.php @@ -54,5 +54,20 @@ class ODBC extends DB_PDO { $sql = "DELETE FROM {$table}"; $this->query($sql); } + + // -------------------------------------------------------------------------- + + /** + * Create sql for batch insert + * + * @param string $table + * @param array $data + * @return string + */ + public function insert_batch($table, $data=array()) + { + // This is not very applicable to the firebird database + return NULL; + } } // End of odbc_driver.php \ No newline at end of file diff --git a/drivers/sqlite/sqlite_driver.php b/drivers/sqlite/sqlite_driver.php index 29e8e78..437aee5 100644 --- a/drivers/sqlite/sqlite_driver.php +++ b/drivers/sqlite/sqlite_driver.php @@ -125,5 +125,20 @@ SQL; $this->statement->execute(); } + + // -------------------------------------------------------------------------- + + /** + * Create sql for batch insert + * + * @param string $table + * @param array $data + * @return string + */ + public function insert_batch($table, $data=array()) + { + // This is not very applicable to the firebird database + return NULL; + } } //End of sqlite_driver.php \ No newline at end of file diff --git a/tests/core/db_qb_test.php b/tests/core/db_qb_test.php index 750df45..00d7395 100644 --- a/tests/core/db_qb_test.php +++ b/tests/core/db_qb_test.php @@ -456,6 +456,35 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- + + public function TestInsertBatch() + { + if (empty($this->db)) return; + + $data = array( + array( + 'id' => 544, + 'key' => 3, + 'val' => 7, + ), + array( + 'id' => 89, + 'key' => 34, + 'val' => 57, + ), + array( + 'id' => 48, + 'key' => 403, + 'val' => 97, + ), + ); + + $query = $this->db->insert_batch('test', $data); + + $this->assertIsA($query, 'PDOStatement'); + } // -------------------------------------------------------------------------- diff --git a/tests/databases/firebird/firebird-qb.php b/tests/databases/firebird/firebird-qb.php index 5497d9c..49676bc 100644 --- a/tests/databases/firebird/firebird-qb.php +++ b/tests/databases/firebird/firebird-qb.php @@ -65,6 +65,8 @@ class FirebirdQBTest extends QBTest { $this->assertNull($query); } + + // -------------------------------------------------------------------------- public function TestTypeList() { diff --git a/tests/databases/sqlite/sqlite-qb.php b/tests/databases/sqlite/sqlite-qb.php index b50e258..4f69c17 100644 --- a/tests/databases/sqlite/sqlite-qb.php +++ b/tests/databases/sqlite/sqlite-qb.php @@ -31,4 +31,33 @@ // echo '
    SQLite Queries
    '; } + + // -------------------------------------------------------------------------- + + public function TestInsertBatch() + { + if (empty($this->db)) return; + + $insert_array = array( + array( + 'id' => 6, + 'key' => 2, + 'val' => 3 + ), + array( + 'id' => 5, + 'key' => 6, + 'val' => 7 + ), + array( + 'id' => 8, + 'key' => 1, + 'val' => 2 + ) + ); + + $query = $this->db->insert_batch('test', $insert_array); + + $this->assertNull($query); + } } \ 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 2db3e914e6636bad01332f3e418ade9ad29a524d..8ff108788a862512d896c21db0370469c2ce00fa 100755 GIT binary patch delta 1300 zcmZ9LF>KR76o%h9PTlya^s2HHN|iK8lQ2Lk1tB&fcGLluE|ihMLKQ@zHY`2}$2`eE(pg5Ds(qH`$~g6>iMV`=Hbcvr?!#L|joE|zvI z^RXO>r4!51SQhrBYfG_lkT1Fo_r*==99+5Ve$U5EcfX1D!o8-Yzs>hWF$w?jHIVKs ztQM;9wNQs+rwA>#2w$98sEm%mpF$a4I%Rn5)M0_1=V@+_=ITxrY#JxWaefS@N9yWT zA4{U6-iBCF-UimhikjHO86i}26D#cw{pu&$o&!Or1lCrnVW?%Q1uPHt18e0+*i!ye zyeO8{w+QDHZefGQQ(YSGMtF`FA9S&(UTI9rSY*IO23(Ydiwrn=iSnp^leN}Kq_cTxo!HjXY^t?wthPCl zjx5tsKFzHz?L=#G0YQc=FvtRfEXa}t23c^%w!pA$?Tl?4jNw?bZLAs2&%pTxoNvJS zSvcQ-^M{326TVSrPc&LiXOu%R8f!*lJw9-bdxV|r7-$_e)#HAk@!1~esLws>fxCU2 z8Ceu?&F-j^9wjj?`|>z{chHM!w~tk|*T>3mMH7NL46#a0ot9|Q)D!$Fx9N)hLEYqo TezVEZwAos!y@``=p5y!fz|9$9 delta 2038 zcmb7FL2FY%5T1Qan&fRl7wpLvN!qkYD$)iMM3k0NOA)~uY>-q!6WS1k(qI+z=1VoN z2d%ZIJ$Uh=mwG5FtyjT=;6ZxuBKQwH)SH)pGjFp=8k*Qn*!MDTXJ=-=`F7T_;+7S^ z&fwzMP7E3%xYbqD=v{~c+`$20uvb3;<}Q4X?4MQ!0u21+9EIVt5d9F!z3*8QwqUj} zY|&*4mo413=(dH&7G7KUc7^E@?CzdBXvWOF*+mX$Ni`_^!GkzkI(m@j2`4+%c1*6+X!pFvis@Xlo=Ct2T-Zl7)=i+T>vjRL8Cp@)`N(1rN(#o1Dv!7Vl@bW&Sx2 zEjCuSgI&XjpaJt$9T=$$8g@P3L-PoG`Vi~}q-DCy6P?ga%j5=640phjeAeWIc&6o# zjpN~&COkuD{l_MAnjpQ#ZpqLSq%fkhV9XRV7GmZ=sjNmp_d zg##mX(l|8hKFB$?4fM(1nm^d6K)ZC@QjD?f6FmnBvhs*wP#H< zt*gwS9$96^>b+Fsl2w^xRVK}C+`%PFnT&VOBQCD2bB->lOF{Q!CocAEEuC6bR_)rUScQhLfQuLxNMQy%(RJV0u Ow^fbPfa=?qeCHoatUzu6