QueryBuilder
extends CI_DB_query_builder
in package
Query Builder.
Table of Contents
Methods
- __construct() : mixed
- Initialize query builder.
- insert() : int
- Insert.
- insert_batch() : array<string|int, int>
- Insert_Batch.
- insert_on_duplicate_update() : int
- Insert_On_Duplicate_Key_Update.
- insert_on_duplicate_update_batch() : int
- Insert_On_Duplicate_Key_Update_Batch.
- isset_qb_from() : bool
- Get QB FROM data.
- load_rdriver() : string
- Load the result drivers.
- query() : mixed
- Execute the query.
- update() : void
- Update.
- update_batch() : int
- Update_Batch.
- _insert_on_duplicate_update() : string
- Insert on duplicate key update statement.
- _insert_on_duplicate_update_batch() : string
- Insert on duplicate key update batch statement.
Methods
__construct()
Initialize query builder.
public
__construct(mixed $config) : mixed
Parameters
- $config : mixed
-
DB Configuration.
insert()
Insert.
public
insert([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ]) : int
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) An associative array of field/value pairs.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
int —Insert ID.
insert_batch()
Insert_Batch.
public
insert_batch(string $table[, array<string|int, mixed>|object $set = null ][, bool $escape = null ][, int $batchSize = 100 ]) : array<string|int, int>
Parameters
- $table : string
-
Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) Data to insert.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
- $batchSize : int = 100
-
(optional) Count of rows to insert at once. Default is 100.
Return values
array<string|int, int> —Insert ID.
insert_on_duplicate_update()
Insert_On_Duplicate_Key_Update.
public
insert_on_duplicate_update([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ]) : int
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) an associative array of insert values.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
int —Insert ID.
insert_on_duplicate_update_batch()
Insert_On_Duplicate_Key_Update_Batch.
public
insert_on_duplicate_update_batch([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ][, int $batchSize = 100 ]) : int
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) an associative array of insert values.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
- $batchSize : int = 100
-
(optional) Count of rows to insert at once. Default is 100.
Return values
int —Number of rows inserted or false on failure.
isset_qb_from()
Get QB FROM data.
public
isset_qb_from([int $index = 0 ]) : bool
Parameters
- $index : int = 0
-
Index of the table name list specified in the from clause. Default is 0.
Return values
bool —QB FROM.
load_rdriver()
Load the result drivers.
public
load_rdriver() : string
Return values
string —the name of the result class.
query()
Execute the query.
public
query(string $sql[, array<string|int, mixed>|false $binds = false ][, bool $returnObject = null ]) : mixed
Parameters
- $sql : string
-
The SQL statement to execute.
- $binds : array<string|int, mixed>|false = false
-
(optional) An array of binding data.
- $returnObject : bool = null
-
(optional) Whether to return a result object or not.
Return values
mixed —true for successful "write-type" queries, CI_DB_result instance (method chaining) on "query" success, false on failure.
update()
Update.
public
update([string $table = '' ][, array<string|int, mixed>|object $set = null ][, string|array<string|int, mixed> $where = null ][, int $limit = null ]) : void
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) An associative array of field/value pairs.
- $where : string|array<string|int, mixed> = null
-
(optional) The WHERE clause.
- $limit : int = null
-
(optional) The LIMIT clause.
update_batch()
Update_Batch.
public
update_batch(string $table[, array<string|int, mixed>|object $set = null ][, string $value = null ][, int $batchSize = 100 ]) : int
Parameters
- $table : string
-
Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) Field name, or an associative array of field/value pairs.
- $value : string = null
-
(optional) Field value, if $set is a single field.
- $batchSize : int = 100
-
(optional) Count of rows to update at once. Default is 100.
Return values
int —Number of rows updated or FALSE on failure
_insert_on_duplicate_update()
Insert on duplicate key update statement.
private
_insert_on_duplicate_update(string $table, array<string|int, mixed> $keys, array<string|int, mixed> $values) : string
Generates a platform-specific insert string from the supplied data.
Parameters
- $table : string
-
Table name.
- $keys : array<string|int, mixed>
-
INSERT keys.
- $values : array<string|int, mixed>
-
INSERT values.
Return values
string —INSERT query.
_insert_on_duplicate_update_batch()
Insert on duplicate key update batch statement.
private
_insert_on_duplicate_update_batch(string $table, array<string|int, mixed> $keys, array<string|int, mixed> $values) : string
Generates a platform-specific insert string from the supplied data.
Parameters
- $table : string
-
Table name
- $keys : array<string|int, mixed>
-
INSERT keys
- $values : array<string|int, mixed>
-
INSERT values
Return values
string —INSERT ON DUPLICATE KEY UPDATE query.