Problem with join and activerecord

#1
[eluser]stoefln[/eluser]
hi guys,

i have following code

Code:
public function getOwnedBy($userId,$limit=20,$offset=0,$orderBy='createdOn DESC'){
        $this->db->select('*');
        $this->db->from('images');
        $this->db->join('owners', 'images.id = owners.imageId');
        $this->db->where('deleted',0);
        $this->db->where('owners.userId',$userId);
        $this->db->order_by('images.'.$orderBy);
        $this->db->limit($limit, $offset);
        $query = $this->db->get();
        $images = $query->result();
        return $this->makeObjects($images);
    }
But when i use the method i get following error:

Code:
A Database Error Occurred
Error Number: 1054
Unknown column 'images.id' in 'on clause'

SELECT * FROM (`images`) JOIN `owners` ON `images`.`id` = `owners`.`imageId` WHERE `deleted` = 0 AND `owners`.`userId` = '1' ORDER BY `images`.`createdOn` DESC LIMIT 20

it seams like there are the ' wrong set
Any ideas?
I use CI 1.7

#2
[eluser]Cristiano Bianchi[/eluser]
Cannot it simply be that you have no images.id field? The query seems fine...
Regards, Cristiano

#3
[eluser]stoefln[/eluser]
i m such a fool! and you are exactly right! i was irretated by the quoting...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.