DBOF_DEBUG_OFF
DBOF_DEBUG_OFF
DEBUG: No Debug Info
Main class definition.
__construct(string $extconfig = '')
Constructor of class.
The constructor takes default values from dbdefs.inc.php. Please see this file for further informations about the setable options.
| string | $extconfig | Optional other filename for dbdefs.inc.php, defaults to "dbdefs.inc.php". |
Connect(string $user = '', string $pass = '', string $host = '', string $db = '', integer $port) : mixed
Performs the connection to MySQL.
If anything goes wrong calls Print_Error().
You should set the defaults for your connection by setting user,pass,host,port and database in dbdefs.inc.php
and leave connect() parameters empty.
If there is an active connection already stored internally this value is returned and no new connection is made.
If MYSQLDB_CHARACTERSET define is set a "SET NAMES '
| string | $user | Username used to connect to DB. |
| string | $pass | Password to use for given username. |
| string | $host | Hostname of database to connect to. |
| string | $db | Schema to use on MySQL DB Server. |
| integer | $port | TCP port to use for connection. Defaults to 3306. |
Either the DB connection handle or NULL in case of an error.
Query(string $querystring, integer $resflag = MYSQLI_ASSOC, integer $no_exit) : mixed
Performs a single-row query and returns result (if one exists).
Resflag can be MYSQLI_NUM or MYSQLI_ASSOC depending on what kind of array you want to be returned.
| string | $querystring | The SQL query to send to database. |
| integer | $resflag | Decides how the result should be returned:
|
| integer | $no_exit | Decides how the class should react on errors. If you set this to 1 the class won't automatically exit on an error but instead return the mysqli_errno value. Default of 0 means that the class calls Print_Error() and exists. |
Either an array as result of the query or an error code or TRUE.
QueryResult(string $querystring, integer $no_exit) : mixed
Performs a multi-row query and returns result identifier.
| string | $querystring | The Query to be executed |
| integer | $no_exit | The error indicator flag, can be one of:
|
A resource identifier or an errorcode (if $no_exit = 1)
FetchResult(mixed $result, integer $resflag = MYSQLI_ASSOC) : array
Fetches next row from result handle.
Returns either numeric (MYSQLI_NUM) or associative (MYSQLI_ASSOC) array for one data row as pointed to by result var.
| mixed | $result | The resource identifier as returned by QueryResult() |
| integer | $resflag | How you want the data to be returned:
|
One row of the resulting query or NULL if there are no data anymore
FreeResult(mixed $result = NULL) : mixed
Frees result returned by QueryResult() and Prepare().
It is a good programming practise to give back what you have taken, so after processing your Multi-Row query with FetchResult() finally call this function to free the allocated memory.
| mixed | $result | The resource identifier you want to be freed. If not given the internal statement handle is used. |
The resulting code of mysqli_free_result (can be ignored).
SetDebug(integer $state)
Sets debug level for debugging of SQL Queries.
$state can have these values:
| integer | $state | The DEBUG Level you want to be set |
SetErrorHandling(integer $val)
Allows to set the class error reporting level in case of an error.
| integer | $val | The Error Handling mode you wish to use. |
SetAutoCommit(boolean $state, mixed $extsock = -1) : boolean
Sets autocommit flag.
| boolean | $state | TRUE = Autocommit enabled, FALSE = autocommit disabled. |
| mixed | $extsock | Optional an external mysqli connect resource, default is internally stored resource. |
The returnvalue of mysqli_autocommit. FALSE in any case if no open link is found.
GetAutoCommit(mixed $extsock = -1) : boolean
Retrieves autocommit flag.
Note that this only works for connected (!) databases, as we have to read the state from the server!
| mixed | $extsock | Optional an external mysqli connect resource. Default is internally stored resource. |
TRUE = autocommit is enabled, FALSE = autocommit is disabled.
ConvertMySQLDate(string $mysqldate, string $fmtstring) : string
Converts a MySQL default Datestring (YYYY-MM-DD HH:MI:SS) into a strftime() compatible format.
You can use all format tags that strftime() supports, this function simply converts the mysql date string into a timestamp which is then passed to strftime together with your supplied format. The converted datestring is then returned. Please do not use this as default date converter, always use DATE_FORMAT() inside a query whenever possible as this is much faster than using this function! Only if you cannot use the MySQL SQL Date converting functions consider using this function.
| string | $mysqldate | The MySQL default datestring in format YYYY-MM-DD HH:MI:SS |
| string | $fmtstring | A strftime() compatible format string. |
The converted date string.
EscapeString(string $str) : string
Escapes a given string with the 'mysqli_real_escape_string' method.
Always use this function to avoid SQL injections when adding dynamic data to MySQL! This function also handles the settings for magic_quotes_gpc/magic_quotes_sybase, if these settings are enabled this function uses stripslashes() first.
| string | $str | The string to escape. |
The escaped string.
Set_TimeNames(string $locale) : integer
Method to set the time_names setting of the MySQL Server.
Pass it a valid locale string to change the locale setting of MySQL. Note that this is supported only since 5.0.25 of MySQL!
| string | $locale | A locale string for the language you want to set, i.e. 'de_DE'. |
0 If an error occures or 1 if change was successful.
Set_CharSet(string $charset) : integer
Method to set the character set of the current connection.
You must specify a valid character set name, else the class will report an error. See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html for a list of supported character sets.
| string | $charset | The charset to set on the MySQL server side. |
1 If all works, else 0 in case of an error.
Get_CharSet() : array
Method to return the current MySQL setting for the character_set variables.
Note that MySQL returns a list of settings, so this method returns all character_set related settings as an associative array.
The current settings for the character_set variables.
Type2TXT(integer $type_id) : mixed|null
Returns text representation for a given column type.
Taken from http://de1.php.net/manual/en/mysqli-result.fetch-field-direct.php#114882
| integer | $type_id | The Id to convert. |
Flags2TXT(integer $flags_num) : string
Returns text representation for column flags.
Taken from http://de1.php.net/manual/en/mysqli-result.fetch-field-direct.php#114882
| integer | $flags_num | The Flags to convert. |
DescTable(string $tname) : array
Returns the description for a given table.
Array returned has the following fields: 0 => name of the field 1 => type of field 2 => The fieldsize 3 => Field flags (like auto_increment).
| string | $tname | Name of table to describe. |
Numerical array with all required table informations.
PerformNewInsert(string $table_name, $fields, string $sql = 'INSERT') : array|boolean
Function performs an insert statement from a given variable list.
The insert statements will be constructed as NEW Insert style, and aligned to the "max_allowed_packet" boundary. This can dramatically improve bulk-inserts compared to fire every INSERT statement one by one. The array passed must be constructed with the keys defined as fieldnames and the values as the corresponding values. Looks like this:
NOTE: Database must be connected!
| string | $table_name | Name of table to perform the insert against. |
| $fields | ||
| string | $sql | Either "INSERT" or "REPLACE", no other command is allowed here! |
A numeric array with [0] => created query count, [1] => Querysize or FALSE in case of an error.
SetPConnect(boolean $conntype) : boolean
Sets connection behavour.
If FALSE class uses mysqli_connect to connect. If TRUE class uses mysqli_connect to connect with prefix "p:" (Persistant connection).
| boolean | $conntype | The new setting for persistant connections. |
The previous state.
Execute(\mysqli_stmt $stmt, integer $no_exit, array $bindvars = null) : boolean|integer|\mysqli_result|null
Executes an prepared statement and optionally bind variables for bindvar-enabled queries.
See examples/test_bind_vars.php for a working example.
| \mysqli_stmt | $stmt | The statement handle as returned by Prepare() |
| integer | $no_exit | Decides how the class should react on errors. If you set this to 1 the class won't automatically exit on an error but instead return the mysqli_errno value. |
| array | $bindvars | Associative array with variables to bind via mysqli_stmt_bind_param(). |
QueryHash(string $querystring, integer $resflag = MYSQLI_ASSOC, integer $no_exit, $bindvars = null) : mixed
Single query method with Bind var support.
Resflag can be "MYSQLI_NUM" or "MYSQLI_ASSOC" depending on what kind of array you want to be returned.
| string | $querystring | The SQL query to send to database. |
| integer | $resflag | Decides how the result should be returned:
|
| integer | $no_exit | Decides how the class should react on errors. If you set this to 1 the class won't automatically exit on an error but instead return the mysqli_errno value. |
| $bindvars |
Either an array as result of the query or an error code or TRUE.
QueryResultHash(string $querystring, integer $no_exit, $bindvars = null) : mixed
Multirow query method with Bind var support.
Resflag can be "MYSQLI_NUM" or "MYSQLI_ASSOC" depending on what kind of array you want to be returned.
| string | $querystring | The SQL query to send to database. |
| integer | $no_exit | Decides how the class should react on errors. If you set this to 1 the class won't automatically exit on an error but instead return the mysqli_errno value. |
| $bindvars |
Either an array as result of the query or an error code or TRUE.
Print_Error(string $ustr = "", mixed $var2dump = "", integer $exit_on_error = 1) : mixed
Prints out MySQL Error in own <div> container and exits.
Please note that this function does not return as long as you have not set db_mysqli::DBOF_RETURN_ALL_ERRORS!
| string | $ustr | User-defined Error string to show |
| mixed | $var2dump | Optionally a variable to print out with print_r() |
| integer | $exit_on_error | If set to default of 1 this function terminates execution of the script by calling exit, else it simply returns. |
Depends on exit_on_error setup either error number or null
SendMailOnError(integer $merrno, string $merrstr, string $uerrstr)
Send error email if programmer has defined a valid email address and enabled it with the define MYSQLDB_SENTMAILONERROR.
| integer | $merrno | MySQL errno number |
| string | $merrstr | MySQL error description |
| string | $uerrstr | User-supplied error description |