Getting content from module

edited February 2013 in Modules
Hi again,

I'm trying to figure out why, what looks proper isn't working:

$CI =& get_instance; $CI->load->module_model('membership','members_model'); $users = $CI->members_model->find_all();

This doesn't return an error, just empty arrays.

Any ideas?
Could something be missing from my model in my module?

Comments

  • edited 5:33AM
    Run the following afterward to see what SQL is being generated and test that SQL outside of FUEL in your MySQL management tool (e.g. Sequel Pro, phpMyAdmin):
    $CI->members_model->debug_query();
  • edited 5:33AM
    Found what the issue is. It's forcing:
    WHERE 'active' = 'yes'
    but since the active column isn't enum, it's tinyint for 1 or 0.

    I used that to minimize complications with the pre-built script I'm using, plus that worked okay in the CMS.

    Perhaps there's a flag I'm missing, or a table class function I can use instead to avoid checking 'active' and allow me to select my own?

    BTW, that's a great piece of code to know! :)
  • edited February 2013
    The active = "yes" is being added by the Base_module_model::_common_query() which is inherited by your model and can be overwritten.

    The _common_query() method is called on every find_* methods to apply extra active record syntax for your results like joins and additional select items.

    Yes... I use debug_query() a lot.
  • edited 5:33AM
    I couldn't figure out how to override it, so I changed the script I was using. Seems to be working great now.
  • edited 5:33AM
    To override the method, just create that method on your model like so:
    function _common_query(){ //... put your content here or nothing at all if you don't want to have a "_common_query" }
  • edited 5:33AM
    Sheesh, too simple. Apparently my mind thinks too much into it :)
    Thanks!
Sign In or Register to comment.