Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter calling model on view?

I have a view which comport a table of data, this data is generated on a model. How can I call this model in my view to be posted on my view...? That's the Equivalent of what I want to do with codeIgniter on php :

while($row = mysql_fetch_array($requet))
      {
// code of displaying my data;
      }
like image 502
Fatim Avatar asked Jan 15 '14 14:01

Fatim


1 Answers

try using $CI =& get_instance()

then load your model like this:

$CI->load->model('someModel')

then call your model function like this:

$result = $CI->someModel->somefunction()

then display using foreach

foreach($result as $row){ $row->somecolumnName }

like image 148
Mohammed Sufian Avatar answered Oct 04 '22 05:10

Mohammed Sufian