⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Filter records when creating relationships?



tanver
  • profile picture
  • Member

Posted 09 December 2011 - 12:55 PM

I am using a flag to mark a record is deleted as opposed to actually deleting the record from my table. Is it possible to use a query instead of a table? or how can I fetch [using a relationship/join] only the records having Active=1?

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 09 December 2011 - 19:29 PM

[quote name='tanver' timestamp='1323435300' post='110']
I am using a flag to mark a record is deleted as opposed to actually deleting the record from my table. Is it possible to use a query instead of a table? or how can I fetch [using a relationship/join] only the records having Active=1?
[/quote]
For a custom query you can use the set_model http://www.grocerycrud.com/crud/function_name/set_model . Now for the fetching you can simply have the where. Just type

$this->grocery_crud->where('active','1');

and you are ready ;-)

tanver
  • profile picture
  • Member

Posted 10 December 2011 - 08:02 AM

Yes, thank you very much, I have to qualify the 'active' with the name of table as it was being used in a relation as well and was ambiguous to the SQL engine.
I am trying to use it in a test project, and so far am very happy with what I was able to achieve with this, thanks for this sharing this wonderful tool with the community.