queries in MY_fuel_layout.php
Basically i need to do some queries in MY_fuel_layout.php
i tried to use $this->load->database() then call $this->db->query() - failed to work
so i think maybe because at the time $this is not reference to any class.
so i switch to CI way of doing
require_once(FUEL_PATH.'models/fuel_pages_model.php');
$CI =& get_instance();
$CI->load->model('fuel_pages_model');
$CI->fuel_pages_model->join('fuel_page_variables', 'fuel_page_variables.page_id = fuel_pages.id');
$result=$CI->fuel_pages_model->find_all(array('fuel_pages.layout'=>'whatsnew_article'));
print_r($result);
exit;
----- above works--------
require_once(FUEL_PATH.'models/fuel_pages_model.php');
$CI =& get_instance();
$CI->load->model('fuel_pages_model');
$CI->fuel_pages_model->join('fuel_page_variables', 'fuel_page_variables.page_id = fuel_pages.id');
$result=$CI->fuel_pages_model->find_all(array('fuel_pages.layout'=>'whatsnew_article','fuel_page_variables.name'=>'title'));
print_r($result);
exit;
------above failed, error, join no a method for model------
How to solve this?
Comments
$CI =& get_instance(); $CI->load->module_model(FUEL_FOLDER, 'fuel_pages_model'); $CI->fuel_pages_model->db()->join('fuel_page_variables', 'fuel_page_variables.page_id = fuel_pages.id'); $result=$CI->fuel_pages_model->find_all(array('fuel_pages.layout'=>'whatsnew_article')); print_r($result); exit;
require_once(FUEL_PATH.'models/fuel_pages_model.php');
$CI =& get_instance();
$CI->load->model('fuel_pages_model');
$CI->fuel_pages_model->join('fuel_page_variables', 'fuel_page_variables.page_id = fuel_pages.id');
$result=$CI->fuel_pages_model->find_all(array('fuel_pages.layout'=>'whatsnew_article','fuel_page_variables.name'=>'title'));
print_r($result);
exit;
which is quite similar to your solution, but does not work, saying join is not a valid method for the model