_common_query() and ambiguous 'id'

edited September 2011 in News & Announcements
Everytime i try to make use of the common_query method (simple left joins) all i get is a
Column 'id' in where clause is ambiguous
error...
It's truly strange, i'm following the example on the user guide (of course on different tables - but the logic should be the same)...

Comments

  • edited 5:24PM
    Ambigous usually suggests that you are referencing a column that has the same name in two tables? Should it be table1.id and table2.id?
  • edited September 2011
    Yep, the problem is on the where() clause - but I can't seem to find out where i can modify the where condition to ask for table.id instead of just id ...
  • edited 5:24PM
    I remember having something similar a while back. I think I went through my code and blanket changed all references to the problematic column to [table].id . Not very clean, but it worked!

    Any further than that and I'm afraid I'm stumped too.

    What does your query look like? Might be useful to post the join query too.
  • edited 5:24PM
    I need to figure out where I can set the db->where() method to look for
    table.id
    instead of
    id
    Wait, does it have anything to do with the var public $filters?
  • edited September 2011
    You can just add the table name in your where statement as in your example above.
  • edited 5:24PM
    i tried adding a $this->db->where() in the _common_query() method but that produced errors actually... ?
  • edited 5:24PM
    What does the query look like if you run the debug_query() method on it (e.g. $this->my_model->debug_query());
Sign In or Register to comment.