Kohana 3 - Query builder gives 0 rows

Posted by pigfox on Stack Overflow See other posts from Stack Overflow or by pigfox
Published on 2010-05-31T21:33:49Z Indexed on 2010/05/31 23:23 UTC
Read the original article Hit count: 267

Filed under:
|
|
|
|

The following query returns one row as expected when run from phpmyadmin.

SELECT units .  * , locations .  *
FROM units, locations
WHERE units.id = '1'
AND units.location_id = locations.id
LIMIT 0 , 30 

But when I try to do it in Kohana 3:

$unit = DB::select('units.*', 'locations.*')
->from('units', 'locations')
->where('units.id', '=', $id)->and_where('units.location_id', '=', 'locations.id')
->execute()->as_array();
var_dump($unit);

It prints

array(0) { }

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about query