Download the PHP package jaypha/mysqli-ext without Composer
On this page you can find all versions of the php package jaypha/mysqli-ext. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mysqli-ext
Jaypha MySQL Ext
Written by Jason den Dulk
A trait containing convenience functions to extend the functionality of the
mysqli
class. These functions reflect very common database related tasks, and
can help reduce code overhead.
Requirements
PHP v5 or greater.
Installation
MySqliExt
As Trait
Must be added to a child of mysqli
.
As Class
API
q($query)
Same as mysqli::query, but throws an exception upon error.
mq($query)
Same as mysqli::multi_query, but throws an exception upon error.
queryValue($query)
Calls q
with $query
and returns a single value. The first value of
the first row.
Returns a string if a value is found and not null, NULL if the value was null, or false if no row was found
queryRow($query, $resultType = MYSQLI_ASSOC)
Calls q
with $query
and returns the first row.
Returns an array if a row was found. If result type is MYSQLI_ASSOC, it will be an associative array. Returns false if no row was found
queryData($query, $keyField = NULL, $resultType = MYSQLI_ASSOC)
Calls q
with $query
and returns the whole data set. If $keyField
is set,
then the values from this column are used as array keys.
Returns an array of rows. Each row is an array. If resultType is MYSQLI_ASSOC, it will be an associative array.
If now rows were found, returns an empty array.
If a key is repeated, it will overwrite any existing value.
queryChunkedData($query, $limit = 1000, $resultType = MYSQLI_ASSOC)
Returns a MySQLiChunkedResult
instance.
queryColumn($query)
Calls q
with $query
and returns a single column. If the SQL query selects
one field, then queryColumn
returns an array containing the values. If the
query selects two or more, then an associative array is returned with the
contents of the first column as the keys and the contents of the second
columns as the values.
If no rows were found, returns an empty array.
If a key is repeated, it will overwrite any existing value.
insert($tableName, $columns, $values = NULL)
A shortcut for insert statements. There are three cases
- If
$values
is NULL, then$columns
is assumed to be an associative array and it is inserted to the database using key/value pairs. - If
$columns
is an array and$values
is an array, then a single row is inserted using$columns
and$values
. - If
$columns
is an array and$values
is an array of arrays, then multiple rows are inserted. Each element of the$values
array is considered a row.
Returns the insert ID value.
update($tableName, $values, $wheres)
A shortcut for update statements.
replace($tableName, $values)
A shortcut for replace statements.
insertUpdate($tableName, $values, $wheres)
Will either insert or update. If a row mathcing the given $wheres
exists, then
it will be updated with the new $values
. Otherwise a new row is inserted with
the $values
and $wheres
combined.
Use this instead of replace when you do not want to destory existing rows.
delete($tableName, $wheres = null)
Shortcut for delete. If $where
is an integer, then it is matched to an id
column.
If $wheres
is null, then it will truncate the table.
get($tableName, int $id)
Selects a row where column 'id' is of value $id
. A column called 'id' must exist.
set($tableName, $values, int $id = 0)
Updates a table row where column 'id' is of value id
. If no id is provided
(i.e. a value of zero), performs an insert instead. A column called 'id' must
exist.
Returns the row's id.
MySQLiChunkedResult
If, for whetever reason, you cannot have an open query, but you also
cannot load the whole query result into memory, then this class works
as a compromise. The result is stored into a temporary table, and then
read in chunks as separate queries. Implements Iterator
so it can be
used with foreach
.
Usage
License
Copyright (C) 2017 Jaypha.
Distributed under the Boost Software License, Version 1.0.
See http://www.boost.org/LICENSE_1_0.txt