$mysqli
$mysqli : \mysqli
DB driver using wpdb for all MySQL access. This allows us to run Dewdrop in a WordPress enironment without creating an additional database connection.
$adapter : \Dewdrop\Db\Adapter
The adapter this driver is attached to.
listMissingForeignKeyIndexes( $tableName) : mixed
List all missing foreign key indexes on the supplied table.
The resulting array has the following shape:
[ ['foreign_key_id'], ['multi_column_foreign_key_id', 'second_column_foreign_key_id'] ]
$tableName |
__construct(\Dewdrop\Db\Adapter $adapter, \wpdb $wpdb = null)
Create new driver using the supplied adapter and wpdb object. If $wpdb is not supplied, we'll attempt to grab the instance created by WordPress itself from the global scope (ugh).
\Dewdrop\Db\Adapter | $adapter | |
\wpdb | $wpdb |
fetchAll(string|\Dewdrop\Db\Select $sql, array $bind = array(), string $fetchMode = null) : array
Fetch all results for the supplied SQL statement.
The SQL query can be a simple string or a Select object. The bind array should supply values for all the parameters, either named or numeric, in the query. And the fetch mode should match one of these 4 class constants from \Dewdrop\Db\Adapter: ARRAY_A, ARRAY_N, OBJECT, or OBJECT_K.
string|\Dewdrop\Db\Select | $sql | |
array | $bind | |
string | $fetchMode |
fetchAllWithGenerator(string|\Dewdrop\Db\Select $sql, array $bind = array(), string $fetchMode = null) : \Generator
Fetch all results for the supplied SQL query using a PHP generator.
This approach uses less memory, but the result set has a forward-only cursor.
The SQL query can be a simple string or a Select object. The bind array should supply values for all the parameters, either named or numeric, in the query. And the fetch mode should match one of these 4 class constants from \Dewdrop\Db\Adapter: ARRAY_A, ARRAY_N, OBJECT, or OBJECT_K.
string|\Dewdrop\Db\Select | $sql | |
array | $bind | |
string | $fetchMode |
fetchCol(string|\Dewdrop\Db\Select $sql, array $bind = array()) : array
Fetch a single column of the results from the supplied SQL statement.
string|\Dewdrop\Db\Select | $sql | |
array | $bind |
fetchOne(string|\Dewdrop\Db\Select $sql, array $bind = array()) : mixed
Fetch a single scalar value from the results of the supplied SQL statement.
string|\Dewdrop\Db\Select | $sql | |
array | $bind |
query(string|\Dewdrop\Db\Select $sql, array $bind = array()) : mixed
Run the supplied query, binding the supplied data to the statement prior to execution.
string|\Dewdrop\Db\Select | $sql | |
array | $bind |
listForeignKeyReferences(string $tableName) : array
Returns an associative array containing all the foreign key relationships associated with the supplied table.
The array has the following format:
array( 'column_name' => array( 'table' => 'foreign_table', 'column' => 'foreign_column' ) )
string | $tableName |
describeTable(string $tableName) : array
Returns the column descriptions for a table.
The return value is an associative array keyed by the column name, as returned by the RDBMS.
The value of each array element is an associative array with the following keys:
SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; COLUMN_NAME => string; column name COLUMN_POSITION => number; ordinal position of column in table DATA_TYPE => string; SQL datatype name of column DEFAULT => string; default expression of column, null if none NULLABLE => boolean; true if column can have nulls LENGTH => number; length of CHAR/VARCHAR SCALE => number; scale of NUMERIC/DECIMAL PRECISION => number; precision of NUMERIC/DECIMAL UNSIGNED => boolean; unsigned property of an integer type PRIMARY => boolean; true if column is part of the primary key PRIMARY_POSITION => integer; position of column in primary key IDENTITY => integer; true if column is auto-generated with unique values
string | $tableName |
mapNativeTypeToGenericType(string $nativeType, mixed $length) : string
Pick an appropriate generic data type for the supplied MySQL native data type.
1) boolean - A true/false value. 2) integer - Whole number. 3) float - Floating point number. 4) text - Fixed-length, shorter text value. 5) clob - Character large object. Large text field. 6) timestamp - Date and time combined. 7) date - Just a date. 8) time - Just the time. 9) money - Get money, get paid. 10) blob - Binary large object.
string | $nativeType | |
mixed | $length |
prepareSelectForTotalRowCalculation(\Dewdrop\Db\Select $select) : void
Use the SQL_CALC_FOUND_ROWS facility in MySQL to calculate the total number of rows that would have been returned from a query if no LIMIT had been applied.
\Dewdrop\Db\Select | $select |
execWpdb(mixed $wpdbResult) : mixed
This method wraps all calls to wpdb. It is used to catch errors generated by database usage in wpdb and bubble them up as thrown exceptions, which work more consistently in other environments than the quirky error tracking wpdb does internally.
mixed | $wpdbResult |