Switch to a different database.
DB::useDB('my_other_database');
Get an array of the tables in the requested database. If no database is specified, use the current database.
$current_db_tables = DB::tableList();
$other_db_tables = DB::tableList('other_db');
foreach ($other_db_tables as $table) {
echo "Table Name: $table\n";
}
Get an array of the columns in the requested table in the current database.
$columns = DB::columnList('accounts');
foreach ($columns as $name => $details) {
echo "Column: $name\n";
echo "Type: " . $details['type'] . "\n";
echo "Null? " . $details['null'] . "\n";
echo "Key: " . $details['key'] . "\n";
echo "Default: " . $details['default'] . "\n";
echo "Extra: " . $details['extra'] . "\n";
}
Drop any existing MySQL connections. If you run a query after this, it will automatically reconnect.
DB::disconnect(); // drop mysqli connection
Return the underlying mysqli object.
$mysqli = DB::get();
Return the last query (whether or not it succeeded).
$query = DB::lastQuery();
Parse a query with args just like DB::query() would, but return it instead of executing
$query = DB::parse("SELECT * FROM accounts WHERE name=%s AND age=%i", 'Joe', 15);
// $query: SELECT * FROM accounts WHERE name='Joe' AND age=15
Change the character that appears before parameters in MeekroDB queries. The default is %
.
DB::$param_char = ':';
$results = DB::query("SELECT * FROM accounts WHERE email=:s", '[email protected]');