⚠ 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

Is there a way to query



bob jones

bob jones
  • profile picture
  • Member

Posted 01 May 2012 - 03:40 AM

Hello,

This is my first post. This is a great library, and will save me a lot of time.I don't understand all the features yet, so I hope this isn't a silly question: I would like to query a table to find the number of rows user 'A' is listed in. If 0 I want to let 'A' add a row, if its greater than 0 give him the opportunity to add, delete or update. My question is : Can grocery CRUD query a table to get the count ofrecords that 'A' owns or should I use other DB tools for this query?

Thank you,

Bob

simonfrank

simonfrank
  • profile picture
  • Member

Posted 01 May 2012 - 14:13 PM

Personally I don't know the internals of it enough yet but I would have thought that the simple solution would be to do your query using codigniter db class, decide whether there are records or not if not redirect to /your_controller/your_crud_ function/add if there are then do the whole grocery_crud logic. By default the default behaviour when there are no records wiorks for me i.e. displays and empty list and you have an add button. Yes you would have the database queried twice but it would be querying the database with many more queries to list then add.

I am sure there is some clever call back you could use to be smarter, but I am still working them out.

bob jones

bob jones
  • profile picture
  • Member

Posted 01 May 2012 - 14:54 PM

Thanks simonfrank