Property | Type | Description | |
---|---|---|---|
$count | string | Variable which holds an amount of returned rows during get/getOne/select queries | |
$pageLimit | integer | Per page limit for pagination | |
$prefix | string | Table prefix | |
$returnType | string | Return type: 'array' to return results as array, 'object' as object 'json' as json string | |
$totalCount | string | Variable which holds an amount of returned rows during get/getOne/select queries with withTotalCount() | |
$totalPages | integer | Variable that holds total pages count of last paginate() query | |
$trace |
Property | Type | Description | |
---|---|---|---|
$_bindParams | array | Dynamic array that holds a combination of where condition/table data value types and parameter references | |
$_forUpdate | boolean | FOR UPDATE flag | |
$_groupBy | array | Dynamic type list for group by condition value | |
$_having | array | An array that holds having conditions | |
$_instance | MysqliDb | Static instance of self | |
$_join | array | An array that holds where joins | |
$_joinAnd | array | An array that holds where join ands | |
$_lastInsertId | integer | Name of the auto increment column | |
$_lastQuery | string | The previously executed SQL query | |
$_lockInShareMode | boolean | LOCK IN SHARE MODE flag | |
$_mapKey | string | Key field for Map()'ed result array | |
$_mysqli | mysqli | MySQLi instance | |
$_nestJoin | boolean | Should join() results be nested by table | |
$_orderBy | array | Dynamic type list for order by condition value | |
$_query | string | The SQL query to be prepared and executed | |
$_queryOptions | string | The SQL query options required after SELECT, INSERT, UPDATE or DELETE | |
$_stmtErrno | integer | Variable which holds last statement error code | |
$_stmtError | string | Variable which holds last statement error | |
$_tableLockMethod | string | Variable which holds the current table lock method. | |
$_tableLocks | array | Dynamic type list for tempromary locking tables. | |
$_updateColumns | array | Column names for update when using onDuplicate method | |
$_where | array | An array that holds where conditions | |
$charset | |||
$db | |||
$host | string | Database credentials | |
$isSubQuery | boolean | Is Subquery object | |
$password | |||
$port | |||
$traceEnabled | |||
$traceStartQ | Variables for query execution tracing | ||
$traceStripPrefix | |||
$username |
Method | Description | |
---|---|---|
__construct ( string $host = null, string $username = null, string $password = null, string $db = null, integer $port = null, string $charset = 'utf8' ) | ||
__destruct ( ) : void | Close connection | |
_buildDataPairs ( array $tableData, array $tableColumns, boolean $isInsert ) | Insert/Update query helper | |
_transaction_status_check ( ) | Shutdown handler to rollback uncommited operations in order to keep atomic operations sane. | |
arrayBuilder ( ) : MysqliDb | Helper function to create dbObject with array return type Added for consistency as thats default output type | |
commit ( ) | Transaction commit | |
connect ( ) : void | A method to connect to the database | |
copy ( ) : MysqliDb | Method returns a copy of a mysqlidb subquery object | |
dec ( integer $num = 1 ) : array | Method generates decrimental function call | |
delete ( string $tableName, integer | array $numRows = null ) : boolean | Delete query. Call the "where" method first. | |
escape ( string $str ) : string | Escape harmful characters which might affect a query. | |
func ( string $expr, array $bindParams = null ) : array | Method generates user defined function call | |
get ( string $tableName, integer | array $numRows = null, string $columns = '*' ) : array | A convenient SELECT * function. | |
getInsertId ( ) : integer | This methods returns the ID of the last inserted item | |
getInstance ( ) : MysqliDb | A method of returning the static instance to allow access to the instantiated object from within another class. | |
getLastErrno ( ) : integer | Method returns mysql error code | |
getLastError ( ) : string | Method returns mysql error | |
getLastQuery ( ) : string | Method returns last executed query | |
getOne ( string $tableName, string $columns = '*' ) : array | A convenient SELECT * function to get one record. | |
getSubQuery ( ) : array | Mostly internal method to get query and its params out of subquery object after get() and getAll() | |
getValue ( string $tableName, string $column, integer $limit = 1 ) : mixed | A convenient SELECT COLUMN function to get a single column value from one row | |
groupBy ( string $groupByField ) : MysqliDb | This method allows you to specify multiple (method chaining optional) GROUP BY statements for SQL queries. | |
has ( string $tableName ) : array | A convenient function that returns TRUE if exists at least an element that satisfy the where condition specified calling the "where" method before this one. | |
having ( string $havingProp, mixed $havingValue = 'DBNULL', string $operator = '=', $cond = 'AND' ) : MysqliDb | This method allows you to specify multiple (method chaining optional) AND HAVING statements for SQL queries. | |
inc ( integer $num = 1 ) : array | Method generates incremental function call | |
insert ( string $tableName, array $insertData ) : boolean | Insert method to add new row | |
insertMulti ( string $tableName, array $multiInsertData, array $dataKeys = null ) : boolean | array | Insert method to add several rows at once | |
interval ( string $diff, string $func = "NOW()" ) : string | Method returns generated interval function as a string | |
join ( string $joinTable, string $joinCondition, string $joinType = '' ) : MysqliDb | This method allows you to concatenate joins for the final SQL statement. | |
joinOrWhere ( string $whereJoin, string $whereProp, mixed $whereValue = 'DBNULL', $operator = '=', $cond = 'AND' ) : dbWrapper | This method allows you to specify multiple (method chaining optional) OR WHERE statements for the join table on part of the SQL query. | |
joinWhere ( string $whereJoin, string $whereProp, mixed $whereValue = 'DBNULL', $operator = '=', $cond = 'AND' ) : dbWrapper | This method allows you to specify multiple (method chaining optional) AND WHERE statements for the join table on part of the SQL query. | |
jsonBuilder ( ) : MysqliDb | Helper function to create dbObject with JSON return type | |
loadData ( string $importTable, string $importFile, string $importSettings = null ) : boolean | This is a basic method which allows you to import raw .CSV data into a table Please check out http://dev.mysql.com/doc/refman/5.7/en/load-data.html for a valid .csv file. | |
loadXml ( string $importTable, string $importFile, string $importSettings = null ) : boolean | This method is usefull for importing XML files into a specific table. | |
lock ( string $table ) : MysqliDb | Locks a table for R/W action. | |
map ( string $idField ) : MysqliDb | Return result as an associative array with $idField field value used as a record key | |
mysqli ( ) : mysqli | A method to get mysqli object or create it in case needed | |
not ( string $col = null ) : array | Method generates change boolean function call | |
now ( string $diff = null, string $func = "NOW()" ) : array | Method returns generated interval function as an insert/update function | |
objectBuilder ( ) : MysqliDb | Helper function to create dbObject with object return type. | |
onDuplicate ( array $updateColumns, string $lastInsertId = null ) : MysqliDb | This function store update column's name and column name of the autoincrement column | |
orHaving ( string $havingProp, mixed $havingValue = null, string $operator = null ) : MysqliDb | This method allows you to specify multiple (method chaining optional) OR HAVING statements for SQL queries. | |
orWhere ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=' ) : MysqliDb | This method allows you to specify multiple (method chaining optional) OR WHERE statements for SQL queries. | |
orderBy ( string $orderByField, $orderbyDirection = "DESC", array $customFields = null ) : MysqliDb | This method allows you to specify multiple (method chaining optional) ORDER BY statements for SQL queries. | |
paginate ( string $table, integer $page, array | string $fields = null ) : array | Pagination wraper to get() | |
ping ( ) : boolean | Method to call mysqli->ping() to keep unused connections open on long-running scripts, or to reconnect timed out connections (if php.ini has global mysqli.reconnect set to true). Can't do this directly using object since _mysqli is protected. | |
query ( string $query, integer | array $numRows = null ) : array | A method to perform select query | |
rawQuery ( string $query, array $bindParams = null ) : array | Execute raw SQL query. | |
rawQueryOne ( string $query, array $bindParams = null ) : array | null | Helper function to execute raw SQL query and return only 1 row of results. | |
rawQueryValue ( string $query, array $bindParams = null ) : mixed | Helper function to execute raw SQL query and return only 1 column of results. | |
replace ( string $tableName, array $insertData ) : boolean | Replace method to add new row | |
rollback ( ) | Transaction rollback function | |
setLockMethod ( string $method ) : MysqliDb | This method sets the current table lock method. | |
setPrefix ( string $prefix = '' ) : MysqliDb | Method to set a prefix | |
setQueryOption ( string | array $options ) : MysqliDb | This method allows you to specify multiple (method chaining optional) options for SQL queries. | |
setTrace ( boolean $enabled, string $stripPrefix = null ) : MysqliDb | Query exection time tracking switch | |
startTransaction ( ) | Begin a transaction | |
subQuery ( string $subQueryAlias = "" ) : MysqliDb | Method creates new mysqlidb object for a subquery generation | |
tableExists ( array $tables ) : boolean | Method to check if needed table is created | |
unlock ( ) : MysqliDb | Unlocks all tables in a database. | |
update ( string $tableName, array $tableData, integer $numRows = null ) : boolean | Update query. Be sure to first call the "where" method. | |
where ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=', string $cond = 'AND' ) : MysqliDb | This method allows you to specify multiple (method chaining optional) AND WHERE statements for SQL queries. | |
withTotalCount ( ) : MysqliDb | Function to enable SQL_CALC_FOUND_ROWS in the get queries |
Method | Description | |
---|---|---|
_bindParam ( $value ) | Helper function to add variables into bind parameters array | |
_bindParams ( array $values ) | Helper function to add variables into bind parameters array in bulk | |
_buildCondition ( string $operator, array &$conditions ) | Abstraction method that will build the part of the WHERE conditions | |
_buildGroupBy ( ) : void | Abstraction method that will build the GROUP BY part of the WHERE statement | |
_buildInsertQuery ( array $tableData ) | Abstraction method that will build an INSERT or UPDATE part of the query | |
_buildJoin ( ) | Abstraction method that will build an JOIN part of the query | |
_buildJoinOld ( ) : void | Abstraction method that will build an JOIN part of the query | |
_buildLimit ( integer | array $numRows ) : void | Abstraction method that will build the LIMIT part of the WHERE statement | |
_buildOnDuplicate ( array $tableData ) | Helper function to add variables into the query statement | |
_buildOrderBy ( ) : void | Abstraction method that will build the LIMIT part of the WHERE statement | |
_buildPair ( string $operator, mixed $value ) : string | Helper function to add variables into bind parameters array and will return its SQL part of the query according to operator in ' $operator ?' or ' $operator ($subquery) ' formats | |
_buildQuery ( integer | array $numRows = null, array $tableData = null ) : mysqli_stmt | Abstraction method that will compile the WHERE statement, any passed update data, and the desired rows. | |
_determineType ( mixed $item ) : string | This method is needed for prepared statements. They require the data type of the field to be bound with "i" s", etc. | |
_dynamicBindResults ( mysqli_stmt $stmt ) : array | This helper method takes care of prepared statements' "bind_result method , when the number of variables to pass is unknown. | |
_prepareQuery ( ) : mysqli_stmt | Method attempts to prepare the SQL query and throws an error if there was a problem. | |
refValues ( array &$arr ) : array | Referenced data array is required by mysqli since PHP 5.3+ | |
replacePlaceHolders ( string $str, array $vals ) : string | Function to replace ? with variables from bind variable | |
reset ( ) : MysqliDb | Reset states after an execution |
Method | Description | |
---|---|---|
_buildInsert ( string $tableName, array $insertData, string $operation ) : boolean | Internal function to build and execute INSERT/REPLACE calls | |
_traceGetCaller ( ) : string | Get where and what function was called for query stored in MysqliDB->trace | |
conditionToSql ( String $operator, String $val ) | Convert a condition and value into the sql string | |
queryUnprepared ( [[Type]] $query ) | Pushes a unprepared statement to the mysqli stack. |
protected _bindParam ( $value ) |
protected _bindParams ( array $values ) | ||
$values | array | Variable with values |
protected _buildCondition ( string $operator, array &$conditions ) | ||
$operator | string | |
$conditions | array |
protected _buildGroupBy ( ) : void | ||
return | void |
protected _buildInsertQuery ( array $tableData ) | ||
$tableData | array |
protected _buildJoin ( ) |
protected _buildJoinOld ( ) : void | ||
return | void |
protected _buildOnDuplicate ( array $tableData ) | ||
$tableData | array | Variable with values |
protected _buildOrderBy ( ) : void | ||
return | void |
protected _buildQuery ( integer | array $numRows = null, array $tableData = null ) : mysqli_stmt | ||
$numRows | integer | array | Array to define SQL limit in format Array ($count, $offset) or only $count |
$tableData | array | Should contain an array of data for updating the database. |
return | mysqli_stmt | Returns the $stmt object. |
protected _determineType ( mixed $item ) : string | ||
$item | mixed | Input to determine the type. |
return | string | The joined parameter types. |
protected _dynamicBindResults ( mysqli_stmt $stmt ) : array | ||
$stmt | mysqli_stmt | Equal to the prepared statement object. |
return | array | The results of the SQL fetch. |
protected _prepareQuery ( ) : mysqli_stmt | ||
return | mysqli_stmt |
public _transaction_status_check ( ) |
public arrayBuilder ( ) : MysqliDb | ||
return | MysqliDb |
public copy ( ) : MysqliDb | ||
return | MysqliDb | new mysqlidb object |
public get ( string $tableName, integer | array $numRows = null, string $columns = '*' ) : array | ||
$tableName | string | The name of the database table to work with. |
$numRows | integer | array | Array to define SQL limit in format Array ($count, $offset) or only $count |
$columns | string | Desired columns |
return | array | Contains the returned rows from the select query. |
public getInsertId ( ) : integer | ||
return | integer | The last inserted item ID. |
public static getInstance ( ) : MysqliDb | ||
return | MysqliDb | Returns the current instance. |
public getLastErrno ( ) : integer | ||
return | integer |
public getLastError ( ) : string | ||
return | string |
public getLastQuery ( ) : string | ||
return | string |
public getSubQuery ( ) : array | ||
return | array |
public getValue ( string $tableName, string $column, integer $limit = 1 ) : mixed | ||
$tableName | string | The name of the database table to work with. |
$column | string | The desired column |
$limit | integer | Limit of rows to select. Use null for unlimited..1 by default |
return | mixed | Contains the value of a returned column / array of values |
public insertMulti ( string $tableName, array $multiInsertData, array $dataKeys = null ) : boolean | array | ||
$tableName | string | The name of the table. |
$multiInsertData | array | Two-dimensinal Data-array containing information for inserting into the DB. |
$dataKeys | array | Optinal Table Key names, if not set in insertDataSet. |
return | boolean | array | Boolean indicating the insertion failed (false), else return id-array ([int]) |
public joinOrWhere ( string $whereJoin, string $whereProp, mixed $whereValue = 'DBNULL', $operator = '=', $cond = 'AND' ) : dbWrapper | ||
$whereJoin | string | The name of the table followed by its prefix. |
$whereProp | string | The name of the database field. |
$whereValue | mixed | The value of the database field. |
return | dbWrapper |
public joinWhere ( string $whereJoin, string $whereProp, mixed $whereValue = 'DBNULL', $operator = '=', $cond = 'AND' ) : dbWrapper | ||
$whereJoin | string | The name of the table followed by its prefix. |
$whereProp | string | The name of the database field. |
$whereValue | mixed | The value of the database field. |
return | dbWrapper |
public jsonBuilder ( ) : MysqliDb | ||
return | MysqliDb |
public loadData ( string $importTable, string $importFile, string $importSettings = null ) : boolean | ||
$importTable | string | The database table where the data will be imported into. |
$importFile | string | The file to be imported. Please use double backslashes \\ and make sure you |
$importSettings | string | An Array defining the import settings as described in the README.md |
return | boolean |
public loadXml ( string $importTable, string $importFile, string $importSettings = null ) : boolean | ||
$importTable | string | The table in which the data will be imported to. |
$importFile | string | The file which contains the .XML data. |
$importSettings | string | An Array defining the import settings as described in the README.md |
return | boolean | Returns true if the import succeeded, false if it failed. |
public mysqli ( ) : mysqli | ||
return | mysqli |
public objectBuilder ( ) : MysqliDb | ||
return | MysqliDb |
public onDuplicate ( array $updateColumns, string $lastInsertId = null ) : MysqliDb | ||
$updateColumns | array | Variable with values |
$lastInsertId | string | Variable value |
return | MysqliDb |
protected reset ( ) : MysqliDb | ||
return | MysqliDb | Returns the current instance. |
public setLockMethod ( string $method ) : MysqliDb | ||
$method | string | The table lock method. Can be READ or WRITE. |
return | MysqliDb |
public setQueryOption ( string | array $options ) : MysqliDb | ||
$options | string | array | The optons name of the query. |
return | MysqliDb |
public tableExists ( array $tables ) : boolean | ||
$tables | array | Table name or an Array of table names to check |
return | boolean | True if table exists |
public where ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=', string $cond = 'AND' ) : MysqliDb | ||
$whereProp | string | The name of the database field. |
$whereValue | mixed | The value of the database field. |
$operator | string | Comparison operator. Default is = |
$cond | string | Condition of where statement (OR, AND) |
return | MysqliDb |
public withTotalCount ( ) : MysqliDb | ||
return | MysqliDb |
protected array $_bindParams | ||
return | array |
protected array $_groupBy | ||
return | array |
protected array $_having | ||
return | array |
protected static MysqliDb $_instance | ||
return | MysqliDb |
protected array $_joinAnd | ||
return | array |
protected int $_lastInsertId | ||
return | integer |
protected string $_lastQuery | ||
return | string |
protected string $_mapKey | ||
return | string |
protected bool $_nestJoin | ||
return | boolean |
protected array $_orderBy | ||
return | array |
protected string $_query | ||
return | string |
protected string $_queryOptions | ||
return | string |
protected int $_stmtErrno | ||
return | integer |
protected string $_stmtError | ||
return | string |
protected string $_tableLockMethod | ||
return | string |
protected array $_tableLocks | ||
return | array |
protected array $_updateColumns | ||
return | array |
protected array $_where | ||
return | array |
public string $count | ||
return | string |
public string $returnType | ||
return | string |
public string $totalCount | ||
return | string |
public int $totalPages | ||
return | integer |