Database

Abstract class BlackFox\Database is an interface that describes access to a relational database.
This class must be overridden in configuration to one of their heirs:

Methods

Title Options Description
Query $SQL, $key = null Must execute any SQL query and return the result as a two-dimensional array if it was a SELECT SQL query
QuerySingleInsert $SQL, $increment = null Must execute an INSERT SQL query and return the last value of the specified column (usually the identifier) ​​
Escape $data Escapes special characters in a string for use in an SQL statement
Quote $data Wraps the string in quotation marks used by the current database to indicate string constants
Random Returns a string describing the SQL random number function
StartTransaction Starts a transaction
Rollback Cancels a transaction
Commit Commit transaction
CompileSQLSelect array $parts Glues an array of parts of a SQL SELECT query into a string
Truncate $table Removes all data from the table and resets its internal counter
Drop $table Deletes a table

Access to global instance

  • In engine and SCRUD contexts: $this->Database->
  • In other contexts: \BlackFox\Database::I()->
$DB = \BlackFox\Database::I();
$users = $DB->Query("SELECT * FROM system_users");
Ask question