开发者

Kohana: Connecting to DB in different ways

I am new to Kohana, and I would like to know what the difference is between:

开发者_开发百科
$query = DB::select()->from('codes')->where('name', '=', 'PHP')->execute($mydb);

$query = DB::query(Database::SELECT, 'SELECT * FROM codes WHERE name = :name');
$query->param(':name', 'PHP');


First one is a Query Builder example. Is prefered way to construct your queries, because it uses only standard SQL commands or keywords, so your code will work after changing DB engine. Query Builder automatically escapes all table names, columns and values.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜