MeekroDB Quick Start Docs FAQ
Download GitHub

Misc Methods and Variables


Switch to a different 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]');


Change the character that separates the name for named parameters. The default is _.

DB::$param_char = ':';
DB::$named_param_seperator = '@';
$results = DB::query("SELECT * FROM accounts WHERE email=:s@email", ['email' => '[email protected]']);


If it's been at least this long since our last query, re-connect to the database before running another query. Defaults to 4 hours, since MySQL's default wait_timeout is 8 hours.

// if MySQL was configured with a wait_timeout of 60 seconds, we should set
// our reconnect to 30 seconds like this
DB::$reconnect_after = 30;