Kohana v3 database, how to get table structure?
How can I using KohanaPHP framework and database module get mysql table structure?
I've tried this:
$query = DB::query(NULL, 'DESCRIB开发者_Go百科E table_name');
$result = $query->execute();
But it only returns number of columns in table, and foreach loop failed.
Is there any other way to get table structure or how can I update code above to works properly?
Try this:
$query = DB::query(NULL, 'SHOW FULL COLUMNS FROM table_name');
$result = $query->execute();
EDIT
You need to specify the type of query of DB::query() will just return the number of affected rows.
$query = DB::query(Database::SELECT, 'SHOW FULL COLUMNS FROM table_name');
$result = $query->execute();
This will give you the result you expect.
精彩评论