Module query keeps returning CI

edited August 2011 in Modules
So as the title says I'm trying to return all the people in my DB table and instead of getting a clean results object I get the CI instance. For full detail:

My module's named "Bio" and it's partly modeled on the "Blog" module.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require_once(MODULES_PATH.'/bio/config/bio_constants.php'); class Bio_core { var $_CI; function __construct() { $this->_CI =& get_instance(); } function sidebar( $query = FALSE ) { $this->_CI->load->module_library(FUEL_FOLDER, 'fuel_pagevars'); $vars['people'] = $this->_get_people( $query ); $output = $this->_render(BIO_FOLDER, '_blocks/sidebar', $vars); return $output; } function _render( $view, $vars = array(), $return=TRUE ) { $output = $this->_CI->load->module_view($view, $vars, $return); $output = $this->_CI->fuel_page->fuelify($output); return $output; } function _get_people( $where = array(), $order_by = NULL, $limit = NULL, $offset = NULL, $return_method = NULL, $assoc_key = NULL ) { $this->_CI->load->module_model(BIO_FOLDER, 'bio_people_model'); $this->_CI->module_model->readonly = TRUE; $people = $this->_CI->bio_people_model->find_all($where, $order_by, $limit, $offset, $return_method, $assoc_key); var_dump($people); return $people; } } /* End of file bio_core.php */ /* Location: ./modules/libraries/bio_core.php */

The query gets called from the _get_people() function and my model for it looks like this:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Bio_people_model extends Base_module_model { public $record_class = 'Bio_person'; public $foreign_keys = array('category_id' => array( 'bio' => 'bio_categories_model')); function __construct() { parent::__construct('bio_people', BIO_FOLDER); // table name } function list_items() { $result = parent::list_items(); return $result; } function find_all($where = array(), $order_by = NULL, $limit = NULL, $offset = NULL, $return_method = NULL, $assoc_key = NULL) { $this->db->select('bio_people.*'); $return = parent::find_all($where = array(), $order_by = NULL, $limit = NULL, $offset = NULL, $return_method = NULL, $assoc_key = NULL); return $return; } function _common_query() { $this->db->join('bio_categories', ''); $this->db->select(',, as category, bio_people.published,'); $result = parent::_common_query(); return $result; } } class Bio_person_model extends Base_module_record { }

Could anybody explain what I'm doing wrong? I really need to get this thing moving. Thanks.


  • edited 10:56AM
    Are you sure it's the $CI object and not an array of "Bio_person_model" objects? What happens when you do the following:
    foreach($people as $person){ print_r($person->values()); }
  • edited 10:56AM
    That actually worked. Thanks. But shouldn't find_all() already return a result set?
  • edited 10:56AM
    it returns an array of Bio_person_model objects. If you use the "get" method, it will return a "Data_set" object
  • edited 10:56AM
    So...using the same method I tried implementing it on a "find_one" command but as of yet with no luck. When I try $this->db->last_query() it returns false.
  • edited 10:56AM
    Nevermind. Realized my mistake. "find_one" items are already returned.
Sign In or Register to comment.