InsertQuery Class
Insert query to add a row to a table
$inserted = $db->insert('user')->values(array(
'first_name' => 'Jim',
'last_name' => 'Smith
));
Constructor
Item Index
Methods
Methods
__toString
()
String
Represent the query as a SQL statement
Returns:
The query in SQL string form
fields
-
fields
The fields to insert into
Returns:
The instance of this query
isAssoc
-
arr
Check to see if an array is associative
Parameters:
-
arr
ArrayThe array to check
Returns:
if the array is associative
limit
-
lengthOrIndex
-
[duration=null]
The limit for query
Parameters:
-
lengthOrIndex
IntEither the single limit number or index, duration
-
[duration=null]
Int optionalHow many rows to fetch
Returns:
The instance of this query
orderBy
-
field
-
[order='asc']
How to order the results by
Parameters:
Returns:
The instance of this query
prepare
-
value
Take an existing value we're about to input and escape it, if needed
Parameters:
-
value
StringA statement or sql property to evaluate
Returns:
A string of an escaped, prepared SQL property
prepareField
-
field
Take an existing field name we're about to input and
Parameters:
-
field
StringThe name of a field
Returns:
A string of an escaped, prepared SQL field name
result
()
Int
Execute the query
Returns:
The id of the last insert
setTables
-
tables
Create and insert query
Returns:
The instance of this query
values
-
values
Add values
Parameters:
-
values
DictionaryThe values to add. Add multiple row by setting the fields() then adding sequential array. Add a single row by passing an associative array of field names to values.
Returns:
The instance of this query