PHP class to manage mysqli DB
See also comments in code.
The last executed query.
Sends a generic query. Also saves the query string to $this->last_query
.
$query
The query stringReturns false
on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries will return a mysqli_result
object. For other successful queries will return true
. See also http://php.net/manual/en/mysqli.query.php.
Creates and sends an ‘INSERT INTO’ query.
$table
The table name$data
Associative array. Keys are field names, Values are field values.The last insert id on success, 0 on failure
$db->insert('Table', [
'Field1' => 'Value1',
'Field2' => 'Value2'
]);
Creates and sends a ‘REPLACE INTO’ query
$table
Table name$data
Associative array. Keys are field names, Values are field values.The last insert id on success, 0 on failure
Creates and sends an ‘UPDATE’ query.
$table
The table name$data
Associative array. Keys are field names, Values are field values.$where
WHERE clause. Items are joined with AND.true
on success, false
on failure
Create and sends an ‘INSERT INTO’ query. On duplicate key sends an ‘UPDATE’ query.
$table
The table name$data
Associative array. Keys are field names, Values are field values.$where
WHERE clause. This became part of $data
in the ‘INSERT INTO’ query, and a real WHERE clause in the ‘UPDATE’ query.Returns false
on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries will return a mysqli_result
object. For other successful queries will return true
. See also http://php.net/manual/en/mysqli.query.php.
Create and sends a ‘SELECT’ query.
$table
Table name$fields
array of fields names or '*'
for all$where
WHERE clause. Items are joined with AND.$orderby
ORDER BY clause. [field_name => 'ASC|DESC', ...]
$limit
LIMIT clause. Use one number to limit results number or two comma separated numbers for paging.For successful queries return a mysqli_result
object. Returns false
on failure.
Creates and sends a ‘DELETE’ query.
$table
Table name$where
WHERE clause. Items are joined with AND.true
on success, false
on failure