Created
May 27, 2013 05:55
-
-
Save kennethdavidbuck/5655383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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