API Reference
DB DB(
[string/resource
$DB_host = null], [string
$DB_name = null], [string
$DB_user = null], [string
$DB_pass = null])
Constuctor, if nothing passed into function will try to get existent MySQL connecton.
- Parameters:
-
string/resource$DB_host - mysql server hostname (or ip address), or mysql link to db (if first parameter is MySQL Link resource, then other three not needed). -
string$DB_name - name of database -
string$DB_user - username -
string$DB_pass - password
Deletes rows from specified table.
- Parameters:
-
string$tableName - name of table -
array$whereParams - array with where params (i.e.: array("id"=>20))
Executes MySQL query and returns MySQL result resource. If MySQL error occurs - outputs query, error and trace information.
- Parameters:
-
string$query - - SQL query
Checks whether specified field exists in specified table.
- Parameters:
-
string$tableName - table name -
string$fieldName - name of filed in table
Returns first column from result set as indexed array.
- Parameters:
-
string$query - query string
Method is usable after using SQL_CALC_FOUND_ROWS statement in your query. Returns total number of found rows.
Returns first row as associative array from result set, if nothing found returns NULL
- Parameters:
-
string$query - query string
Returns indexed array of rows returned by MySQL.
- Parameters:
-
string$query - - select query
Use this function, if you have used SQL_CALC_FOUND_ROWS and want to obtain how much was found at all
Returns first row, first column from result set, useful for getting scalars (count(), max(), id and so on).
if nothing found returns -1
- Parameters:
-
string$query - - query string
Returns WHERE SQL statement based on search string and search fields.
- Parameters:
-
string[]$fields - indexed array with fields to be searched -
string$searchString - search string -
int$searchType - search type, 0 = At least 1 word, 1 = All words
Returns WHERE statement by specified associative array
- Parameters:
-
string$tableName - - name of table -
array$params - - associative array with
Returns first row, first column from result
if nothing found, returns null
- Parameters:
-
string$query - query string
Inserts new row to table and returns insert id, on failure returns -1
- Parameters:
-
string$tableName - name of table -
array$params - array in following format: array[string fieldname] = object fieldvalue
End profiler and returns it's result
- Parameters:
-
$name$name - name of profiler
Starts profiler, profiler is needed to obtain which query takes most of time and how much times each query is executed
- Parameters:
-
string$name - name of profiler (also needed to stop profiler), needed since different profilers can run parallel
Similiar to update, if entry doesn't exists, Inserts a new one
- Parameters:
-
string$tableName - name of table -
array$params - array in following format: array[string fieldname] = object fieldvalue -
array$whereParams - array with where params for example array("id"=>20)
Saves all executed queries into file.
- Parameters:
-
string$filename - - filename -
bool$append - - optional parameter to append or not to file (default false) -
string$title - - optional parameter for file header
Returns true if specified table exists
- Parameters:
-
string$tableName - name of table