Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

fuel_model returning empty?

edited November 2016 in Modules
I have a simple module and it works on the backend. I added one record, but now when I call the model from the frontend, my query returns empty:
$vars['display'] = fuel_model('gallery', array('find' => 'all')); var_dump($vars['display']);

This returns empty. Any idea why? What can I change in my model that might be affecting this?

Thanks in advance!

Comments

  • edited 4:05AM
    Here's the beginning of my model code. I omitted a lot of functions because the post was too long.

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Gallery_model extends Base_module_model { public $required = array(); function __construct() { parent::__construct('zwell_gallery'); // table name $this->load->model('galleryvariables_model'); } function list_items($limit = NULL, $offset = NULL, $col = 'zwell_gallery.master_order', $order = 'DESC') { $this->db->select('id, slug, layout, published, featured', FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; } function _common_query() { parent::_common_query(); // to do active and published $this->db->order_by('master_order DESC'); } } ?>
  • edited 4:05AM
    SOLVED:
    My 'published' field was set to TINYINT(1, 0) rather than ENUM('yes', 'no'), so my queries were never seeing the published records.
  • edited 4:05AM
    Glad you figured it out. You can set the model's $boolean_fields property to include the "published" field. This will allow you to toggle the published state in the list view. Also, this behavior takes place in the Base_module_model::_common_query() method which you can override in your model. It looks for fields of "published" or "active" that are enums or are specified in the $boolean_fields property on the model.
Sign In or Register to comment.