Jump to content


custom model filter ambigous

custom model filter ambigous

  • Please log in to reply
4 replies to this topic

#1 Racing Chocobo

Racing Chocobo

    Member

  • Members
  • PipPip
  • 28 posts

Posted 06 August 2013 - 05:55 PM

Hi guys,

 

I have some problems with custom model while implementing filter function.

I went through the forum and find about this problem, and I find a solution about the filtering, by adding something like this:

function get_total_results() {

      $this->db->from($this->table_name);

      $this->db->join();
    
      return $this->db->count_all_results();
}

However, this solution works well in general multi join table that has different field name, but whenever I met with two join table that has same field name, it will occur error:

 

Column 'content' in where clause is ambiguous

 

I realized this problem occured since I've joined two tables that has field name 'content' separately, so when I do the filter function for the column 'content', it will say that it ambigous.

 

It's is there any implementable method to handle with this problem?

 

I've tried so many method to solved this problem, but nothing worked until now.

 

Thousands of thanks for you all~



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 07 August 2013 - 04:49 AM

Try to use the following structure on the field names;

tablename.fieldname. This might resolve it.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 Racing Chocobo

Racing Chocobo

    Member

  • Members
  • PipPip
  • 28 posts

Posted 07 August 2013 - 01:27 PM

Yeah, I've tried for many2 times and many method, but still can't solved this problem, the problem is because everytime it filter, it only throw the 'content' instead of tablename.fieldname

I donno whether my method is wrong for getting the tablename.fieldname or any other problems, I've tried so many times, but still can't work.

$_select = array(
       'missions.sn, missions.target_num, mission_type.name, mission_text.content, good_text.title'
       );

that's one of my tries, I've already put the tablename before the fieldname, but while it do filtering, it still only search for 'content' instead of 'mission_text.content'

Thank you very much for the reply~



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 07 August 2013 - 09:57 PM

Well I propose you enable the profiler to see what is going on with the queries that are generated.

In general follow these guidelines for debugging.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 12 August 2013 - 02:26 PM

Well David,

i did encounter this issue in past. I did alter the grocery crud base library to fix it. When looking for filter, if not mistakend it was in - set_ajax_list_queries

i managed to fix it with adding _unique_field_name call to some other places too - it sets it if there is an relation to avoid the abmigious field call .. but for some reason, i still was getting it and i had set it other places too.. and the problem was solved..

 

Here also a similar approach may be applied to get the desired result set if i find the code some place, i surely will post it.. but if i dont, .. the above solutuion specified is a good way to solve.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users