Property | Type | Description | |
---|---|---|---|
$ThrowExceptions | Determines if an error throws an exception | ||
$mysql_link | class-internal variables - do not change |
Method | Description | |
---|---|---|
AutoInsertUpdate ( string $tableName, array $valuesArray, array $whereArray ) : boolean | Automatically does an INSERT or UPDATE depending if an existing record exists in a table | |
BeginningOfSeek ( ) : boolean | Returns true if the internal pointer is at the beginning of the records | |
BuildSQLDelete ( string $tableName, array $whereArray = null ) : string | [STATIC] Builds a SQL DELETE statement | |
BuildSQLInsert ( string $tableName, array $valuesArray ) : string | [STATIC] Builds a SQL INSERT statement | |
BuildSQLSelect ( string $tableName, array $whereArray = null, array/string $columns = null, array/string $sortColumns = null, boolean $sortAscending = true, integer/string $limit = null ) : string | Builds a simple SQL SELECT statement | |
BuildSQLUpdate ( string $tableName, array $valuesArray, array $whereArray = null ) : string | [STATIC] Builds a SQL UPDATE statement | |
BuildSQLWhereClause ( array $whereArray ) : string | [STATIC] Builds a SQL WHERE clause from an array. | |
Close ( ) : object | Close current MySQL connection | |
DeleteRows ( string $tableName, array $whereArray = null ) : boolean | Deletes rows in a table based on a WHERE filter (can be just one or many rows based on the filter) | |
EndOfSeek ( ) : boolean | Returns true if the internal pointer is at the end of the records | |
Error ( ) : string | Returns the last MySQL error as text | |
ErrorNumber ( ) : integer | Returns the last MySQL error as a number | |
GetBooleanValue ( mixed $value ) : boolean | [STATIC] Converts any value of any datatype into boolean (true or false) | |
GetColumnComments ( string $table ) : array | Returns the comments for fields in a table into an array or NULL if the table has not got any fields | |
GetColumnCount ( string $table = "" ) : integer | This function returns the number of columns or returns FALSE on error | |
GetColumnDataType ( string $column, string $table = "" ) : string | This function returns the data type for a specified column. If the column does not exists or no records exist, it returns FALSE | |
GetColumnID ( string $column, string $table = "" ) : integer | This function returns the position of a column | |
GetColumnLength ( string $column, string $table = "" ) : integer | This function returns the field length or returns FALSE on error | |
GetColumnName ( string $columnID, string $table = "" ) : integer | This function returns the name for a specified column number. If the index does not exists or no records exist, it returns FALSE | |
GetColumnNames ( string $table = "" ) : array | Returns the field names in a table or query in an array | |
GetHTML ( boolean $showCount = true, string $styleTable = null, string $styleHeader = null, string $styleData = null ) : string | This function returns the last query as an HTML table | |
GetJSON ( ) : string | Returns the last query as a JSON document | |
GetLastInsertID ( ) : integer | Returns the last autonumber ID field from a previous INSERT query | |
GetLastSQL ( ) : string | Returns the last SQL statement executed | |
GetTables ( ) : array | This function returns table names from the database into an array. If the database does not contains any tables, the returned value is FALSE | |
GetXML ( ) : string | Returns the last query as an XML Document | |
HasRecords ( string $sql = "" ) : boolean | Determines if a query contains any rows | |
InsertRow ( string $tableName, array $valuesArray ) : integer | Inserts a row into a table in the connected database | |
IsConnected ( ) : boolean | Determines if a valid connection to the database exists | |
IsDate ( date/string $value ) : boolean | [STATIC] Determines if a value of any data type is a date PHP can convert | |
Kill ( $message = "" ) | Stop executing (die/exit) and show last MySQL error message | |
MoveFirst ( ) : boolean | Seeks to the beginning of the records | |
MoveLast ( ) : boolean | Seeks to the end of the records | |
Open ( string $database = null, string $server = null, string $username = null, string $password = null, string $charset = null, boolean $pcon = false ) : boolean | Connect to specified MySQL server | |
Query ( string $sql ) : object | Executes the given SQL query and returns the records | |
QueryArray ( string $sql, integer $resultType = MYSQLI_BOTH ) : array | Executes the given SQL query and returns a multi-dimensional array | |
QuerySingleRow ( string $sql ) : object | Executes the given SQL query and returns only one (the first) row | |
QuerySingleRowArray ( string $sql, integer $resultType = MYSQLI_BOTH ) : array | Executes the given SQL query and returns the first row as an array | |
QuerySingleValue ( string $sql ) : mixed | Executes a query and returns a single value. If more than one row is returned, only the first value in the first column is returned. | |
QueryTimed ( string $sql ) : object | Executes the given SQL query, measures it, and saves the total duration in microseconds | |
Records ( ) : object | Returns the records from the last query | |
RecordsArray ( integer $resultType = MYSQLI_BOTH ) : Records | Returns all records from last query and returns contents as array or FALSE on error | |
Release ( ) : boolean | Frees memory used by the query results and returns the function result | |
Row ( integer $optional_row_number = null ) : object | Reads the current row and returns contents as a PHP object or returns false on error | |
RowArray ( integer $optional_row_number = null, integer $resultType = MYSQLI_BOTH ) : array | Reads the current row and returns contents as an array or returns false on error | |
RowCount ( ) : integer | Returns the last query row count | |
SQLBooleanValue ( mixed $value, mixed $trueValue, mixed $falseValue, string $datatype = self::SQLVALUE_TEXT ) : string | [STATIC] Converts a boolean into a formatted TRUE or FALSE value of choice | |
SQLFix ( string $value ) : string | Returns string suitable for SQL NOTE: This is no longer a static call because of a conflict with mysqli_real_escape_string. | |
SQLValue ( mixed $value, string $datatype = self::SQLVALUE_TEXT ) : string | [STATIC] Formats any value into a string suitable for SQL statements (NOTE: Also supports data types returned from the gettype function) | |
Seek ( integer $row_number ) : object | Sets the internal database pointer to the specified row number and returns the result | |
SeekPosition ( ) : integer | Returns the current cursor row location | |
SelectDatabase ( string $database, string $charset = "" ) : boolean | Selects a different database and character set | |
SelectRows ( string $tableName, array $whereArray = null, array/string $columns = null, array/string $sortColumns = null, boolean $sortAscending = true, integer/string $limit = null ) : boolean | Gets rows in a table based on a WHERE filter | |
SelectTable ( string $tableName ) : boolean | Retrieves all rows in a specified table | |
TimerDuration ( integer $decimals = 4 ) : Float | Returns last measured duration (time between TimerStart and TimerStop) | |
TimerStart ( ) | Starts time measurement (in microseconds) | |
TimerStop ( ) | Stops time measurement (in microseconds) | |
TransactionBegin ( ) : boolean | Starts a transaction | |
TransactionEnd ( ) : boolean | Ends a transaction and commits the queries | |
TransactionRollback ( ) : boolean | Rolls the transaction back | |
TruncateTable ( string $tableName ) : boolean | Truncates a table removing all data | |
UpdateRows ( string $tableName, array $valuesArray, array $whereArray = null ) : boolean | Updates rows in a table based on a WHERE filter (can be just one or many rows based on the filter) | |
__construct ( boolean $connect = true, string $database = null, string $server = null, string $username = null, string $password = null, string $charset = null ) | Constructor: Opens the connection to the database | |
__destruct ( ) | Destructor: Closes the connection to the database |
Method | Description | |
---|---|---|
BuildSQLColumns ( $columns, boolean $addQuotes = true, boolean $showAlias = true ) : string | [STATIC] Builds a comma delimited list of columns for use with SQL | |
ResetError ( ) | Clears the internal variables from any error information | |
SetError ( string $errorMessage = "", integer $errorNumber ) | Sets the local variables with the last error information |
public AutoInsertUpdate ( string $tableName, array $valuesArray, array $whereArray ) : boolean | ||
$tableName | string | The name of the table |
$valuesArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
$whereArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). |
return | boolean | Returns TRUE on success or FALSE on error |
public BeginningOfSeek ( ) : boolean | ||
return | boolean | TRUE if at the first row or FALSE if not |
public static BuildSQLDelete ( string $tableName, array $whereArray = null ) : string | ||
$tableName | string | The name of the table |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). If not specified then all values in the table are deleted. |
return | string | Returns the SQL DELETE statement |
public static BuildSQLInsert ( string $tableName, array $valuesArray ) : string | ||
$tableName | string | The name of the table |
$valuesArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
return | string | Returns a SQL INSERT statement |
public static BuildSQLSelect ( string $tableName, array $whereArray = null, array/string $columns = null, array/string $sortColumns = null, boolean $sortAscending = true, integer/string $limit = null ) : string | ||
$tableName | string | The name of the table |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
$columns | array/string | |
$sortColumns | array/string | |
$sortAscending | boolean | (Optional) TRUE for ascending; FALSE for descending This only works if $sortColumns are specified |
$limit | integer/string | |
return | string | Returns a SQL SELECT statement |
public static BuildSQLUpdate ( string $tableName, array $valuesArray, array $whereArray = null ) : string | ||
$tableName | string | The name of the table |
$valuesArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). If not specified then all values in the table are updated. |
return | string | Returns a SQL UPDATE statement |
public static BuildSQLWhereClause ( array $whereArray ) : string | ||
$whereArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
return | string | Returns a string containing the SQL WHERE clause |
public DeleteRows ( string $tableName, array $whereArray = null ) : boolean | ||
$tableName | string | The name of the table |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). If not specified then all values in the table are deleted. |
return | boolean | Returns TRUE on success or FALSE on error |
public ErrorNumber ( ) : integer | ||
return | integer | Error number from last known error |
public static GetBooleanValue ( mixed $value ) : boolean | ||
$value | mixed | Value to analyze for TRUE or FALSE |
return | boolean | Returns TRUE or FALSE |
public GetColumnComments ( string $table ) : array | ||
$table | string | Table name |
return | array | An array that contains the column comments |
public GetColumnCount ( string $table = "" ) : integer | ||
$table | string | (Optional) If a table name is not specified, the column count is returned from the last query |
return | integer | The total count of columns |
public GetColumnNames ( string $table = "" ) : array | ||
$table | string | (Optional) If a table name is not specified, the last returned records are used |
return | array | An array that contains the column names |
public GetHTML ( boolean $showCount = true, string $styleTable = null, string $styleHeader = null, string $styleData = null ) : string | ||
$showCount | boolean | (Optional) TRUE if you want to show the row count, FALSE if you do not want to show the count |
$styleTable | string | (Optional) Style information for the table |
$styleHeader | string | (Optional) Style information for the header row |
$styleData | string | (Optional) Style information for the cells |
return | string | HTML containing a table with all records listed |
public GetLastInsertID ( ) : integer | ||
return | integer | ID number from previous INSERT query |
public GetLastSQL ( ) : string | ||
return | string | Current SQL query string |
public HasRecords ( string $sql = "" ) : boolean | ||
$sql | string | [Optional] If specified, the query is first executed Otherwise, the last query is used for comparison |
return | boolean | TRUE if records exist, FALSE if not or query error |
public InsertRow ( string $tableName, array $valuesArray ) : integer | ||
$tableName | string | The name of the table |
$valuesArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
return | integer | Returns last insert ID on success or FALSE on failure |
public IsConnected ( ) : boolean | ||
return | boolean | TRUE idf connectect or FALSE if not connected |
public Kill ( $message = "" ) |
public Open ( string $database = null, string $server = null, string $username = null, string $password = null, string $charset = null, boolean $pcon = false ) : boolean | ||
$database | string | (Optional) Database name |
$server | string | (Optional) Host address |
$username | string | (Optional) User name |
$password | string | (Optional) Password |
$charset | string | (Optional) Character set |
$pcon | boolean | (Optional) Persistant connection |
return | boolean | Returns TRUE on success or FALSE on error |
public Query ( string $sql ) : object | ||
$sql | string | The query string should not end with a semicolon |
return | object | PHP 'mysql result' resource object containing the records on SELECT, SHOW, DESCRIBE or EXPLAIN queries and returns; TRUE or FALSE for all others i.e. UPDATE, DELETE, DROP AND FALSE on all errors (setting the local Error message) |
public QueryArray ( string $sql, integer $resultType = MYSQLI_BOTH ) : array | ||
$sql | string | The query string should not end with a semicolon |
$resultType | integer | (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH |
return | array | A multi-dimensional array containing all the data returned from the query or FALSE on all errors |
public QuerySingleRow ( string $sql ) : object | ||
$sql | string | The query string should not end with a semicolon |
return | object | PHP resource object containing the first row or FALSE if no row is returned from the query |
public QuerySingleRowArray ( string $sql, integer $resultType = MYSQLI_BOTH ) : array | ||
$sql | string | The query string should not end with a semicolon |
$resultType | integer | (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH |
return | array | An array containing the first row or FALSE if no row is returned from the query |
public QuerySingleValue ( string $sql ) : mixed | ||
$sql | string | The query string should not end with a semicolon |
return | mixed | The value returned or FALSE if no value |
public QueryTimed ( string $sql ) : object | ||
$sql | string | The query string should not end with a semicolon |
return | object | PHP 'mysql result' resource object containing the records on SELECT, SHOW, DESCRIBE or EXPLAIN queries and returns TRUE or FALSE for all others i.e. UPDATE, DELETE, DROP |
public RecordsArray ( integer $resultType = MYSQLI_BOTH ) : Records | ||
$resultType | integer | (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH |
return | Records | in array form |
public RowArray ( integer $optional_row_number = null, integer $resultType = MYSQLI_BOTH ) : array | ||
$optional_row_number | integer | (Optional) Use to specify a row |
$resultType | integer | (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH |
return | array | Array that corresponds to fetched row or FALSE if no rows |
public static SQLBooleanValue ( mixed $value, mixed $trueValue, mixed $falseValue, string $datatype = self::SQLVALUE_TEXT ) : string | ||
$value | mixed | value to analyze for TRUE or FALSE |
$trueValue | mixed | value to use if TRUE |
$falseValue | mixed | value to use if FALSE |
$datatype | string | Use SQLVALUE constants or the strings: string, text, varchar, char, boolean, bool, Y-N, T-F, bit, date, datetime, time, integer, int, number, double, float |
return | string | SQL formatted value of the specified data type |
public static SQLValue ( mixed $value, string $datatype = self::SQLVALUE_TEXT ) : string | ||
$value | mixed | Any value of any type to be formatted to SQL |
$datatype | string | Use SQLVALUE constants or the strings: string, text, varchar, char, boolean, bool, Y-N, T-F, bit, date, datetime, time, integer, int, number, double, float |
return | string |
public SeekPosition ( ) : integer | ||
return | integer | Current row number |
public SelectRows ( string $tableName, array $whereArray = null, array/string $columns = null, array/string $sortColumns = null, boolean $sortAscending = true, integer/string $limit = null ) : boolean | ||
$tableName | string | The name of the table |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
$columns | array/string | |
$sortColumns | array/string | |
$sortAscending | boolean | (Optional) TRUE for ascending; FALSE for descending This only works if $sortColumns are specified |
$limit | integer/string | |
return | boolean | Returns records on success or FALSE on error |
public SelectTable ( string $tableName ) : boolean | ||
$tableName | string | The name of the table |
return | boolean | Returns records on success or FALSE on error |
public TimerDuration ( integer $decimals = 4 ) : Float | ||
$decimals | integer | (Optional) The number of decimal places to show |
return | Float | Microseconds elapsed |
public TransactionBegin ( ) : boolean | ||
return | boolean | Returns TRUE on success or FALSE on error |
public TransactionEnd ( ) : boolean | ||
return | boolean | Returns TRUE on success or FALSE on error |
public TransactionRollback ( ) : boolean | ||
return | boolean | Returns TRUE on success or FALSE on failure |
public TruncateTable ( string $tableName ) : boolean | ||
$tableName | string | The name of the table |
return | boolean | Returns TRUE on success or FALSE on error |
public UpdateRows ( string $tableName, array $valuesArray, array $whereArray = null ) : boolean | ||
$tableName | string | The name of the table |
$valuesArray | array | An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect) |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). If not specified then all values in the table are updated. |
return | boolean | Returns TRUE on success or FALSE on error |
public __construct ( boolean $connect = true, string $database = null, string $server = null, string $username = null, string $password = null, string $charset = null ) | ||
$connect | boolean | (Optional) Auto-connect when object is created |
$database | string | (Optional) Database name |
$server | string | (Optional) Host address |
$username | string | (Optional) User name |
$password | string | (Optional) Password |
$charset | string | (Optional) Character set |