Skip to content

Instantly share code, notes, and snippets.

@kennethdavidbuck
Created May 27, 2013 05:55
Show Gist options
  • Save kennethdavidbuck/5655383 to your computer and use it in GitHub Desktop.
Save kennethdavidbuck/5655383 to your computer and use it in GitHub Desktop.
<?php
namespace Api;
class Metum {
/**
* Table Field metadata
*/
public static function fields($table)
{
return \DB::select(\DB::raw("show fields from $table"));
}
/**
* Table field key data
*/
public static function keys($table)
{
return \DB::select(\DB::raw("show keys from $table"));
}
/**
* Database tables data
* @return an array of table names in the database
*/
public static function tables()
{
$database = \DB::select(\DB::raw('select DATABASE()'))[0]->{'DATABASE()'};
$property = "Tables_in_$database";
foreach($tables = \DB::select(\DB::raw('show tables')) as $key=>$table)
{
$tables[$key] = $table->{$property};
}
return $tables;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment