Database class

The following sections explain each method of the class.

quefetch


public Array quefetch ( string $sql)

With the method quefetch single-line results can be from SELECT read out the instructions.

Parameter list
sql

The SQL SELECT statement that ultimately selects the element in the database and thus returns.


result_array


public Array result_array ( string $sql)

This method is similar to the quefetch method. Only provides result_array a result of not only back but several. The SQL query must be this one SELECT be statement.

Parameter list
sql

The SQL SELECT statement that ultimately selected the items in the database and thus returns.


multi_query


public Boolean multi_query ( string $sql)

With the method multi_query multiple SQL commands can be run simultaneously. This can for example several INSERT commands hang together. These are processed then step by step. This saves resources and less loaded the database.

Parameter list
sql

The SQL statement that all commands in a string with a semicolon (;) separated with each other lists.


multi_query_safety (from v2.4.0)


public Boolean multi_query_safety ( string $sql, array $execute)

Using the method multi_query_safety can be at once to process multiple neatly query statements. Other than the method multi_query process used here on the prepared statement.

Parameter list
sql

The SQL statement that all commands in a string with a semicolon (;) separated with each other lists.

execute

Contains an array containing the values represented by the placeholders? Should be replaced. A sample SQL query: INSERT INTO `table` SET` field` = ? Then the execute array would look like this: $execute = array ('meinWert') The Prepared Statements method then makes the following: INSERT INTO `table` SET`field` = "myValue" . It checks whether the value "myWert" for SQL contains malicious code and cleans this.


version


public mixed version ()

Returns the currently installed driver version.


insert_id


public Integer insert_id ( String $name = null)

Returns the most recently added PRIMARY KEY a INSERT command returns.

Parameter list
name

The name of the INSERT command of the PRIMARY KEY should be returned. By default null, therefore the last INSERT command.


safetyQuery


public Mixed safetyQuery ( String $sql, Array $execute, Boolean $isResultAssociative = true, Boolean $getFirstResult = false)

Performs a Prepared Statements command off and goes all parameters passed without damaging thus ensure that SQL code will be written to the database.

Parameter list
sql

The SQL command to be executed. This should values by the placeholder? to be replaced. These placeholders are by the contents in the parameter execute by the Prepared Statements procedure safely replaced.

execute

Contains an array containing the values represented by the placeholders? Should be replaced. A sample SQL query: INSERT INTO `table` SET` field` = ? Then the execute array would look like this: $execute = array ('meinWert') The Prepared Statements method then makes the following: INSERT INTO `table` SET`field` = "myValue" . It checks whether the value "myWert" for SQL contains malicious code and cleans this.

isResultAssociative

If it is a SELECT request is you can here determine that an associative array to be returned. Is the value false set a Boolean Returns response, convenient for INSERT , UPDATE or DELETE commands.

getFirstResult

If it is a SELECT request is and you want to have only the first result of this returned result you can here a true entering. By defaultfalse


insertTable (MySQL)


public Boolean insertTable ( String $table, Array $setParameter)

Inserts a value into the database table.

Parameter list
table

The table name to the value to be added to.

setParameter

An array with the key (field name) and value(field values) values that are necessary for the table.


updateTable (MySQL)


public Boolean updateTable ( String $table, Array $setParameter, Array $whereParameter, int $limit = 0)

Updates one or more values in a table

Parameter list
table

The table name in which the values should be updated.

setParameter

The SET parameter in an array, where the key is the field name and the value of the field value.

whereParameter

The WHERE conditions of the UPDATE statement. Where key field name and value of the field value. Field values may contain also MySQL internal functions. That means the method detects whether it is a default value, or to an internal MySQL function.

limit

Can you limit how much you want maximum update. By default, 0, means everything.


deleteTable (MySQL)


public Boolean deleteTable ( String $table, Array $whereParameter, int $limit = 0)

Deletes records from a database table out.

Parameter list
table

The table name from which to delete the content.

whereParameter

The WHERE conditions for the DELETE command. This applies, key is the field name and value of the field value. MySQL are considered functions and recognized.

limit

The number of maximum to delete content. By default, 0, means everything that is found.



The Database class detects whether certain content is just pure content or MySQL functions and makes them as a plague out. Here a list of MySQL functions which can be detected:

  • ABS()
  • ACOS()
  • ADDDATE()
  • ADDTIME()
  • AES_DECRYPT()
  • AES_ENCRYPT()
  • ANY_VALUE()
  • ASCII()
  • ASIN()
  • ASYMMETRIC()
  • ATAN()
  • AVG()
  • BENCHMARK()
  • BETWEEN()
  • BIN()
  • BIT_AND()
  • BIT_COUNT()
  • BIT_LENGTH()
  • BIT_OR()
  • BIT_XOR()
  • CAST()
  • CEIL()
  • CHAR()
  • COALESCE()
  • COERCIBILITY()
  • COLLATION()
  • COMPRESS()
  • CONCAT()
  • CONNECTION_ID()
  • CONV()
  • COS()
  • COT()
  • COUNT()
  • CRC32()
  • CREATE_*
  • CURDATE()
  • CURRENT_*
  • CURTIME()
  • DATABASE()
  • DATE_*
  • DATE()
  • DAY()
  • DECODE()
  • DEFAULT()
  • DEGREES()
  • ELT()
  • ENCODE()
  • EXP()
  • EXTRACT()
  • FIELD()
  • FIND_IN_SET()
  • FLOOR()
  • FORMAT()
  • FOUND_*
  • FROM_*
  • GET_*
  • GREATEST()
  • GROUP_*
  • GTID_*
  • HEX()
  • HOUR()
  • IF()
  • IN()
  • IS_*
  • ISNULL()
  • JSON_*
  • LAST_*
  • LCASE()
  • LEAST()
  • LEFT()
  • LENGTH()
  • LIKE()
  • LN()
  • LOAD_*
  • LOCAL()
  • LOCATE()
  • LOG()
  • LOWER()
  • LPAD()
  • LTRIM()
  • MAKE_*
  • MAKEDATE()
  • MAKETIME()
  • MASTER_POS_WAIT()
  • MATCH()
  • MAX()
  • MBR()
  • MD5()
  • MICROSECOND()
  • MID()
  • MIN()
  • MLine()
  • MOD()
  • MONTH()
  • MPointFrom()
  • MPolyFrom()
  • MultiLineString()
  • MultiPoint()
  • MultiPolygon()
  • NAME_CONST()
  • NOT BETWEEN()
  • NOT IN()
  • NOT LIKE()
  • NOT REGEXP()
  • NOT()
  • NOW()
  • NULLIF()
  • OCT()
  • OLD_PASSWORD()
  • ORD()
  • PERIOD_ADD()
  • PERIOD_DIFF()
  • PI()
  • Point()
  • Polygon()
  • POSITION()
  • POW()
  • PROCEDURE()
  • ANALYSE()
  • QUARTER()
  • QUOTE()
  • RADIANS()
  • RAND()
  • REGEXP()
  • RELEASE_*
  • REPEAT()
  • REPLACE()
  • REVERSE()
  • RIGHT()
  • RLIKE()
  • ROUND()
  • ROW_*
  • RPAD()
  • RTRIM()
  • SCHEMA()
  • SEC_TO_TIME()
  • SECOND()
  • SESSION_USER()
  • SHA()
  • SIGN()
  • SIN()
  • SLEEP()
  • SOUNDEX()
  • SOUND_*
  • SPACE()
  • SQRT()
  • ST_*
  • STD()
  • STDDEV()
  • STR_TO_DATE()
  • STRCMP()
  • SUB()
  • SUM()
  • SYSDATE()
  • SYSTEM_USER()
  • TAN()
  • TIME()
  • TO_*
  • TRIM()
  • TRUNCATE()
  • UCASE()
  • UNCOMPRESS()
  • UNHEX()
  • UNIX()
  • UpdateXML()
  • UPPER()
  • USER()
  • UTC_*
  • UUID()
  • VALIDATE_PASSWORD_STRENGTH()
  • VALUES()
  • VAR_*
  • VARIANCE()
  • VERSION()
  • WAIT_*
  • WEEK()
  • WEIGHT_STRING()
  • XOR()
  • YEAR()