开发者

Kohana v3 database, how to get table structure?

开发者 https://www.devze.com 2023-03-22 18:43 出处:网络
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\');

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消