[eluser]RJ[/eluser]
Hello,
I'm trying to utilize the $this->load->vars method to enable use of vars in the view. Below in a Model I am first grabbing all db data for a specific dealer, then adding to session(probably remove that eventually), then trying to make those variables returned to database usable in my views.
Code:
if (isset($dealer) && $dealer !='')
{
$this->vars = $this->grab_vars($dealer); // use dealer var to grab info from db,
$this->session->set_userdata('dealer',$this->vars); // add dealer info to session
// makes all dealer vars available in views where var['name'] is seen in view as $name
$this->load->vars($this->vars);
}
And here is my grab_vars method
Code:
function grab_vars($dealer)
{
$this->db->select('*')->where('num', $dealer);
$query = $this->db->get('fw_dealers');
// change to array
$res = $query->result_array();
// log array
log_message('debug', $this->db->last_query());
if (!$query)
{
show_error('Can not find dealer in our database, please contact customer support.');
$this->load->model('shop_model'); // load model
$this->shop_model->logging($res, 'DEALER-CLASS'); // write to log file
}
else
{
return $res;
}
}
and this is what my array looks like
Code:
Array
(
[0] => Array
(
[num] => 999
[name] => FindWhere, Inc.
[countries] => US,BR,DE,FR,MX,NL,UK,US
[vatnum] => NLxxxxxx
[bcolor] => cccccc
[acolor] => ffffff
[hcolor] => ace0f1
[rr1] =>
[rr2] =>
[rr3] =>
[rr_title_color] =>
[image] =>
[s_image] =>
[instid] => 88858
)
)
Loading those vars does not make them usable in a view. Any suggestions?