I'm wondering what is the best way to pass a query result + a separate piece of text from a model to a view.
My model
$query = $this->db->query("SELECT * from ci_wizard_results WHERE `tblresultrequestsource` LIKE '%".$countryqueryresult->countrytld."%' AND tblresultkioskname = '' ".$sqlkioskfilter." ORDER BY ci_wizard_results.tblresultdatetime DESC");
$querytext = "some text"
return $query->result();
Controller:
$data['yunbe_selectall'] = $this->wizard_model->yunbe_selectall();
View:
<?php foreach($yunbe_selectall as $yunbe_selectallrow) { ?>
<tr>
<td><?php echo $yunbe_selectallrow->tblresultrefid;?></td>
<td><?php echo $yunbe_selectallrow->tblresultdatetime;?></td>
<td><?php echo $yunbe_selectallrow->tblresultip;?></td>
<td><?php echo $yunbe_selectallrow->tblresultrequestsource;?></td>
I want to display "$querytext" into the view. I know it would be better to put each return in a different function, but since there are some complicated query's in the function to get to the result, I'd like to avoid to duplicate it.
I tried passing it as an array, but I can't manage to get it displayed.
Thanks!!
</div>
You are on the right track with an array:
query = $this->db->query("SELECT * from ci_wizard_results WHERE `tblresultrequestsource` LIKE '%".$countryqueryresult->countrytld."%' AND tblresultkioskname = '' ".$sqlkioskfilter." ORDER BY ci_wizard_results.tblresultdatetime DESC");
$querytext = "some text"
return array('text'=>$querytext, 'result'=>$query->result());
Controller:
$data['yunbe_selectall'] = $this->wizard_model->yunbe_selectall();
View:
<h2><?php echo $yunbe_selectall['text'];?></h2>
<?php foreach($yunbe_selectall['result'] as $yunbe_selectallrow) { ?>