tags:

views:

53

answers:

1

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');
+3  A: 

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.

biakaveron