开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜