Reputation: 1570
I'm bit confuse how to convert my query :
> SELECT COUNT(`id`) AS `total_logs`, `userlog`.* FROM `user_log` AS
> `userlog` WHERE `user_id` = '31' AND date(`date_created`) =
> '2012-04-30'
to Kohana 3.1 ORM? currently i m using :
> $isLoged = ORM::factory('Userlog')->select(array('COUNT("id")',
> 'total_logs'))
> ->where('user_id', '=', $user->id)
> ->and_where('Date(date_created)', '=', date('Y-m-d'))
> ->find_all();
unfortunately above one is giving error :(
Database_Exception [ 1054 ]: Unknown column 'Date(date_created)' in 'where cla....
Upvotes: 1
Views: 1900
Reputation: 137320
'Date(date_created)'
string will be escaped and treated as a column name, unless you will first pass it to DB::expr()
. Thus instead of 'Date(date_created)'
try the following:
DB::expr('Date(date_created)')
See the documentation on DB::expr()
.
Upvotes: 3