PHP 클래스 MysqliDb, PHP-MySQLi-Database-Class

파일 보기 프로젝트 열기: joshcam/PHP-MySQLi-Database-Class 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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

보호된 프로퍼티들

프로퍼티 타입 설명
$_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

공개 메소드들

메소드 설명
__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

보호된 메소드들

메소드 설명
_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

비공개 메소드들

메소드 설명
_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.

메소드 상세

__construct() 공개 메소드

public __construct ( string $host = null, string $username = null, string $password = null, string $db = null, integer $port = null, string $charset = 'utf8' )
$host string
$username string
$password string
$db string
$port integer
$charset string

__destruct() 공개 메소드

Close connection
public __destruct ( ) : void
리턴 void

_bindParam() 보호된 메소드

Helper function to add variables into bind parameters array
protected _bindParam ( $value )

_bindParams() 보호된 메소드

Helper function to add variables into bind parameters array in bulk
protected _bindParams ( array $values )
$values array Variable with values

_buildCondition() 보호된 메소드

Abstraction method that will build the part of the WHERE conditions
protected _buildCondition ( string $operator, array &$conditions )
$operator string
$conditions array

_buildDataPairs() 공개 메소드

Insert/Update query helper
public _buildDataPairs ( array $tableData, array $tableColumns, boolean $isInsert )
$tableData array
$tableColumns array
$isInsert boolean INSERT operation flag

_buildGroupBy() 보호된 메소드

Abstraction method that will build the GROUP BY part of the WHERE statement
protected _buildGroupBy ( ) : void
리턴 void

_buildInsertQuery() 보호된 메소드

Abstraction method that will build an INSERT or UPDATE part of the query
protected _buildInsertQuery ( array $tableData )
$tableData array

_buildJoin() 보호된 메소드

Abstraction method that will build an JOIN part of the query
protected _buildJoin ( )

_buildJoinOld() 보호된 메소드

Abstraction method that will build an JOIN part of the query
protected _buildJoinOld ( ) : void
리턴 void

_buildLimit() 보호된 메소드

Abstraction method that will build the LIMIT part of the WHERE statement
protected _buildLimit ( integer | array $numRows ) : void
$numRows integer | array Array to define SQL limit in format Array ($count, $offset) or only $count
리턴 void

_buildOnDuplicate() 보호된 메소드

Helper function to add variables into the query statement
protected _buildOnDuplicate ( array $tableData )
$tableData array Variable with values

_buildOrderBy() 보호된 메소드

Abstraction method that will build the LIMIT part of the WHERE statement
protected _buildOrderBy ( ) : void
리턴 void

_buildPair() 보호된 메소드

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
protected _buildPair ( string $operator, mixed $value ) : string
$operator string
$value mixed Variable with values
리턴 string

_buildQuery() 보호된 메소드

It then builds the SQL query.
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.
리턴 mysqli_stmt Returns the $stmt object.

_determineType() 보호된 메소드

This function takes the input, determines what type it is, and then updates the param_type.
protected _determineType ( mixed $item ) : string
$item mixed Input to determine the type.
리턴 string The joined parameter types.

_dynamicBindResults() 보호된 메소드

This helper method takes care of prepared statements' "bind_result method , when the number of variables to pass is unknown.
protected _dynamicBindResults ( mysqli_stmt $stmt ) : array
$stmt mysqli_stmt Equal to the prepared statement object.
리턴 array The results of the SQL fetch.

_prepareQuery() 보호된 메소드

Method attempts to prepare the SQL query and throws an error if there was a problem.
protected _prepareQuery ( ) : mysqli_stmt
리턴 mysqli_stmt

_transaction_status_check() 공개 메소드

Shutdown handler to rollback uncommited operations in order to keep atomic operations sane.

arrayBuilder() 공개 메소드

Helper function to create dbObject with array return type Added for consistency as thats default output type
public arrayBuilder ( ) : MysqliDb
리턴 MysqliDb

commit() 공개 메소드

Transaction commit
public commit ( )

connect() 공개 메소드

A method to connect to the database
public connect ( ) : void
리턴 void

copy() 공개 메소드

Method returns a copy of a mysqlidb subquery object
public copy ( ) : MysqliDb
리턴 MysqliDb new mysqlidb object

dec() 공개 메소드

Method generates decrimental function call
public dec ( integer $num = 1 ) : array
$num integer increment by int or float. 1 by default
리턴 array

delete() 공개 메소드

Delete query. Call the "where" method first.
public delete ( string $tableName, integer | array $numRows = null ) : boolean
$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
리턴 boolean Indicates success. 0 or 1.

escape() 공개 메소드

Escape harmful characters which might affect a query.
public escape ( string $str ) : string
$str string The string to escape.
리턴 string The escaped string.

func() 공개 메소드

Method generates user defined function call
public func ( string $expr, array $bindParams = null ) : array
$expr string user function body
$bindParams array
리턴 array

get() 공개 메소드

A convenient SELECT * function.
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
리턴 array Contains the returned rows from the select query.

getInsertId() 공개 메소드

This methods returns the ID of the last inserted item
public getInsertId ( ) : integer
리턴 integer The last inserted item ID.

getInstance() 공개 정적인 메소드

Inheriting this class would require reloading connection info.
public static getInstance ( ) : MysqliDb
리턴 MysqliDb Returns the current instance.

getLastErrno() 공개 메소드

Method returns mysql error code
public getLastErrno ( ) : integer
리턴 integer

getLastError() 공개 메소드

Method returns mysql error
public getLastError ( ) : string
리턴 string

getLastQuery() 공개 메소드

Method returns last executed query
public getLastQuery ( ) : string
리턴 string

getOne() 공개 메소드

A convenient SELECT * function to get one record.
public getOne ( string $tableName, string $columns = '*' ) : array
$tableName string The name of the database table to work with.
$columns string Desired columns
리턴 array Contains the returned rows from the select query.

getSubQuery() 공개 메소드

Mostly internal method to get query and its params out of subquery object after get() and getAll()
public getSubQuery ( ) : array
리턴 array

getValue() 공개 메소드

A convenient SELECT COLUMN function to get a single column value from one row
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
리턴 mixed Contains the value of a returned column / array of values

groupBy() 공개 메소드

This method allows you to specify multiple (method chaining optional) GROUP BY statements for SQL queries.
public groupBy ( string $groupByField ) : MysqliDb
$groupByField string The name of the database field.
리턴 MysqliDb

has() 공개 메소드

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.
public has ( string $tableName ) : array
$tableName string The name of the database table to work with.
리턴 array Contains the returned rows from the select query.

having() 공개 메소드

This method allows you to specify multiple (method chaining optional) AND HAVING statements for SQL queries.
public having ( string $havingProp, mixed $havingValue = 'DBNULL', string $operator = '=', $cond = 'AND' ) : MysqliDb
$havingProp string The name of the database field.
$havingValue mixed The value of the database field.
$operator string Comparison operator. Default is =
리턴 MysqliDb

inc() 공개 메소드

Method generates incremental function call
public inc ( integer $num = 1 ) : array
$num integer increment by int or float. 1 by default
리턴 array

insert() 공개 메소드

Insert method to add new row
public insert ( string $tableName, array $insertData ) : boolean
$tableName string The name of the table.
$insertData array Data containing information for inserting into the DB.
리턴 boolean Boolean indicating whether the insert query was completed succesfully.

insertMulti() 공개 메소드

Insert method to add several rows at once
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.
리턴 boolean | array Boolean indicating the insertion failed (false), else return id-array ([int])

interval() 공개 메소드

Method returns generated interval function as a string
public interval ( string $diff, string $func = "NOW()" ) : string
$diff string interval in the formats: "1", "-1d" or "- 1 day" -- For interval - 1 day Supported intervals [s]econd, [m]inute, [h]hour, [d]day, [M]onth, [Y]ear Default null;
$func string Initial date
리턴 string

join() 공개 메소드

This method allows you to concatenate joins for the final SQL statement.
public join ( string $joinTable, string $joinCondition, string $joinType = '' ) : MysqliDb
$joinTable string The name of the table.
$joinCondition string the condition.
$joinType string 'LEFT', 'INNER' etc.
리턴 MysqliDb

joinOrWhere() 공개 메소드

This method allows you to specify multiple (method chaining optional) OR WHERE statements for the join table on part of the SQL query.
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.
리턴 dbWrapper

joinWhere() 공개 메소드

This method allows you to specify multiple (method chaining optional) AND WHERE statements for the join table on part of the SQL query.
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.
리턴 dbWrapper

jsonBuilder() 공개 메소드

Helper function to create dbObject with JSON return type
public jsonBuilder ( ) : MysqliDb
리턴 MysqliDb

loadData() 공개 메소드

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.
저자: Jonas Barascu (Noneatme)
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
리턴 boolean

loadXml() 공개 메소드

Check out the LOAD XML syntax for your MySQL server.
저자: Jonas Barascu
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
리턴 boolean Returns true if the import succeeded, false if it failed.

lock() 공개 메소드

Locks a table for R/W action.
저자: Jonas Barascu
public lock ( string $table ) : MysqliDb
$table string The table to be locked. Can be a table or a view.
리턴 MysqliDb if succeeeded;

map() 공개 메소드

Array Returns an array($k => $v) if get(.."param1, param2"), array ($k => array ($v, $v)) otherwise
public map ( string $idField ) : MysqliDb
$idField string field name to use for a mapped element key
리턴 MysqliDb

mysqli() 공개 메소드

A method to get mysqli object or create it in case needed
public mysqli ( ) : mysqli
리턴 mysqli

not() 공개 메소드

Method generates change boolean function call
public not ( string $col = null ) : array
$col string column name. null by default
리턴 array

now() 공개 메소드

Method returns generated interval function as an insert/update function
public now ( string $diff = null, string $func = "NOW()" ) : array
$diff string interval in the formats: "1", "-1d" or "- 1 day" -- For interval - 1 day Supported intervals [s]econd, [m]inute, [h]hour, [d]day, [M]onth, [Y]ear Default null;
$func string Initial date
리턴 array

objectBuilder() 공개 메소드

Helper function to create dbObject with object return type.
public objectBuilder ( ) : MysqliDb
리턴 MysqliDb

onDuplicate() 공개 메소드

This function store update column's name and column name of the autoincrement column
public onDuplicate ( array $updateColumns, string $lastInsertId = null ) : MysqliDb
$updateColumns array Variable with values
$lastInsertId string Variable value
리턴 MysqliDb

orHaving() 공개 메소드

This method allows you to specify multiple (method chaining optional) OR HAVING statements for SQL queries.
public orHaving ( string $havingProp, mixed $havingValue = null, string $operator = null ) : MysqliDb
$havingProp string The name of the database field.
$havingValue mixed The value of the database field.
$operator string Comparison operator. Default is =
리턴 MysqliDb

orWhere() 공개 메소드

This method allows you to specify multiple (method chaining optional) OR WHERE statements for SQL queries.
public orWhere ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=' ) : MysqliDb
$whereProp string The name of the database field.
$whereValue mixed The value of the database field.
$operator string Comparison operator. Default is =
리턴 MysqliDb

orderBy() 공개 메소드

This method allows you to specify multiple (method chaining optional) ORDER BY statements for SQL queries.
public orderBy ( string $orderByField, $orderbyDirection = "DESC", array $customFields = null ) : MysqliDb
$orderByField string The name of the database field.
$customFields array Fieldset for ORDER BY FIELD() ordering
리턴 MysqliDb

paginate() 공개 메소드

Pagination wraper to get()
public paginate ( string $table, integer $page, array | string $fields = null ) : array
$table string The name of the database table to work with
$page integer Page number
$fields array | string Array or coma separated list of fields to fetch
리턴 array

ping() 공개 메소드

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.
public ping ( ) : boolean
리턴 boolean True if connection is up

query() 공개 메소드

A method to perform select query
public query ( string $query, integer | array $numRows = null ) : array
$query string Contains a user-provided select query.
$numRows integer | array Array to define SQL limit in format Array ($count, $offset)
리턴 array Contains the returned rows from the query.

rawQuery() 공개 메소드

Execute raw SQL query.
public rawQuery ( string $query, array $bindParams = null ) : array
$query string User-provided query to execute.
$bindParams array Variables array to bind to the SQL statement.
리턴 array Contains the returned rows from the query.

rawQueryOne() 공개 메소드

Note that function do not add 'limit 1' to the query by itself Same idea as getOne()
public rawQueryOne ( string $query, array $bindParams = null ) : array | null
$query string User-provided query to execute.
$bindParams array Variables array to bind to the SQL statement.
리턴 array | null Contains the returned row from the query.

rawQueryValue() 공개 메소드

If 'limit 1' will be found, then string will be returned instead of array Same idea as getValue()
public rawQueryValue ( string $query, array $bindParams = null ) : mixed
$query string User-provided query to execute.
$bindParams array Variables array to bind to the SQL statement.
리턴 mixed Contains the returned rows from the query.

refValues() 보호된 메소드

Referenced data array is required by mysqli since PHP 5.3+
protected refValues ( array &$arr ) : array
$arr array
리턴 array

replace() 공개 메소드

Replace method to add new row
public replace ( string $tableName, array $insertData ) : boolean
$tableName string The name of the table.
$insertData array Data containing information for inserting into the DB.
리턴 boolean Boolean indicating whether the insert query was completed succesfully.

replacePlaceHolders() 보호된 메소드

Function to replace ? with variables from bind variable
protected replacePlaceHolders ( string $str, array $vals ) : string
$str string
$vals array
리턴 string

reset() 보호된 메소드

Reset states after an execution
protected reset ( ) : MysqliDb
리턴 MysqliDb Returns the current instance.

rollback() 공개 메소드

Transaction rollback function
public rollback ( )

setLockMethod() 공개 메소드

This method sets the current table lock method.
저자: Jonas Barascu
public setLockMethod ( string $method ) : MysqliDb
$method string The table lock method. Can be READ or WRITE.
리턴 MysqliDb

setPrefix() 공개 메소드

Method to set a prefix
public setPrefix ( string $prefix = '' ) : MysqliDb
$prefix string Contains a tableprefix
리턴 MysqliDb

setQueryOption() 공개 메소드

This method allows you to specify multiple (method chaining optional) options for SQL queries.
public setQueryOption ( string | array $options ) : MysqliDb
$options string | array The optons name of the query.
리턴 MysqliDb

setTrace() 공개 메소드

Query exection time tracking switch
public setTrace ( boolean $enabled, string $stripPrefix = null ) : MysqliDb
$enabled boolean Enable execution time tracking
$stripPrefix string Prefix to strip from the path in exec log
리턴 MysqliDb

startTransaction() 공개 메소드

Begin a transaction
public startTransaction ( )

subQuery() 공개 정적인 메소드

Method creates new mysqlidb object for a subquery generation
public static subQuery ( string $subQueryAlias = "" ) : MysqliDb
$subQueryAlias string
리턴 MysqliDb

tableExists() 공개 메소드

Method to check if needed table is created
public tableExists ( array $tables ) : boolean
$tables array Table name or an Array of table names to check
리턴 boolean True if table exists

unlock() 공개 메소드

Also commits transactions.
저자: Jonas Barascu
public unlock ( ) : MysqliDb
리턴 MysqliDb

update() 공개 메소드

Update query. Be sure to first call the "where" method.
public update ( string $tableName, array $tableData, integer $numRows = null ) : boolean
$tableName string The name of the database table to work with.
$tableData array Array of data to update the desired row.
$numRows integer Limit on the number of rows that can be updated.
리턴 boolean

where() 공개 메소드

This method allows you to specify multiple (method chaining optional) AND WHERE statements for SQL queries.
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)
리턴 MysqliDb

withTotalCount() 공개 메소드

Function to enable SQL_CALC_FOUND_ROWS in the get queries
public withTotalCount ( ) : MysqliDb
리턴 MysqliDb

프로퍼티 상세

$_bindParams 보호되어 있는 프로퍼티

Dynamic array that holds a combination of where condition/table data value types and parameter references
protected array $_bindParams
리턴 array

$_forUpdate 보호되어 있는 프로퍼티

FOR UPDATE flag
protected bool $_forUpdate
리턴 boolean

$_groupBy 보호되어 있는 프로퍼티

Dynamic type list for group by condition value
protected array $_groupBy
리턴 array

$_having 보호되어 있는 프로퍼티

An array that holds having conditions
protected array $_having
리턴 array

$_instance 보호되어 있는 정적으로 프로퍼티

Static instance of self
protected static MysqliDb $_instance
리턴 MysqliDb

$_join 보호되어 있는 프로퍼티

An array that holds where joins
protected array $_join
리턴 array

$_joinAnd 보호되어 있는 프로퍼티

An array that holds where join ands
protected array $_joinAnd
리턴 array

$_lastInsertId 보호되어 있는 프로퍼티

Name of the auto increment column
protected int $_lastInsertId
리턴 integer

$_lastQuery 보호되어 있는 프로퍼티

The previously executed SQL query
protected string $_lastQuery
리턴 string

$_lockInShareMode 보호되어 있는 프로퍼티

LOCK IN SHARE MODE flag
protected bool $_lockInShareMode
리턴 boolean

$_mapKey 보호되어 있는 프로퍼티

Key field for Map()'ed result array
protected string $_mapKey
리턴 string

$_mysqli 보호되어 있는 프로퍼티

MySQLi instance
protected mysqli $_mysqli
리턴 mysqli

$_nestJoin 보호되어 있는 프로퍼티

Should join() results be nested by table
protected bool $_nestJoin
리턴 boolean

$_orderBy 보호되어 있는 프로퍼티

Dynamic type list for order by condition value
protected array $_orderBy
리턴 array

$_query 보호되어 있는 프로퍼티

The SQL query to be prepared and executed
protected string $_query
리턴 string

$_queryOptions 보호되어 있는 프로퍼티

The SQL query options required after SELECT, INSERT, UPDATE or DELETE
protected string $_queryOptions
리턴 string

$_stmtErrno 보호되어 있는 프로퍼티

Variable which holds last statement error code
protected int $_stmtErrno
리턴 integer

$_stmtError 보호되어 있는 프로퍼티

Variable which holds last statement error
protected string $_stmtError
리턴 string

$_tableLockMethod 보호되어 있는 프로퍼티

Variable which holds the current table lock method.
protected string $_tableLockMethod
리턴 string

$_tableLocks 보호되어 있는 프로퍼티

Dynamic type list for tempromary locking tables.
protected array $_tableLocks
리턴 array

$_updateColumns 보호되어 있는 프로퍼티

Column names for update when using onDuplicate method
protected array $_updateColumns
리턴 array

$_where 보호되어 있는 프로퍼티

An array that holds where conditions
protected array $_where
리턴 array

$charset 보호되어 있는 프로퍼티

protected $charset

$count 공개적으로 프로퍼티

Variable which holds an amount of returned rows during get/getOne/select queries
public string $count
리턴 string

$db 보호되어 있는 프로퍼티

protected $db

$host 보호되어 있는 프로퍼티

Database credentials
protected string $host
리턴 string

$isSubQuery 보호되어 있는 프로퍼티

Is Subquery object
protected bool $isSubQuery
리턴 boolean

$pageLimit 공개적으로 프로퍼티

Per page limit for pagination
public int $pageLimit
리턴 integer

$password 보호되어 있는 프로퍼티

protected $password

$port 보호되어 있는 프로퍼티

protected $port

$prefix 공개적으로 정적으로 프로퍼티

Table prefix
public static string $prefix
리턴 string

$returnType 공개적으로 프로퍼티

Return type: 'array' to return results as array, 'object' as object 'json' as json string
public string $returnType
리턴 string

$totalCount 공개적으로 프로퍼티

Variable which holds an amount of returned rows during get/getOne/select queries with withTotalCount()
public string $totalCount
리턴 string

$totalPages 공개적으로 프로퍼티

Variable that holds total pages count of last paginate() query
public int $totalPages
리턴 integer

$trace 공개적으로 프로퍼티

public $trace

$traceEnabled 보호되어 있는 프로퍼티

protected $traceEnabled

$traceStartQ 보호되어 있는 프로퍼티

Variables for query execution tracing
protected $traceStartQ

$traceStripPrefix 보호되어 있는 프로퍼티

protected $traceStripPrefix

$username 보호되어 있는 프로퍼티

protected $username