php - CodeIgniter Message: Class 'Model' not found -


hello guys trying connect database data using codeigniter , there code:

i getting error:

fatal error: class 'model' not found in /applications/mamp/htdocs/ci/application/models/data_model.php on line 3

a php error encountered

severity: warning

message: cannot modify header information - headers sent (output started @ /applications/mamp/htdocs/ci/application/models/data_model.php:3)

filename: core/common.php

line number: 569

backtrace:

a php error encountered

severity: error

message: class 'model' not found filename: models/data_model.php

line number: 3 backtrace:

models: data_model.php:

<?php   class data_model extends model {       function getall(){          $q  = $this->db->query("select * data");          if($q->num_rows() > 0) {              foreach ($q->result() $row) {                 $data [] = $row;             }             return $data;         }      } } 

views: home.php

<html>  <body>   <div> view has been loaded</div>   <!--<p>  <?php echo $myvalue; ?> </p>  <p>  <?php echo $anothervalue; ?> </p> -->    <pre>  <?php foreach ($rows $r) {     echo '<h1>' . $r->title . '</h1>'; } ?> </pre>  </body>   </html> 

controllers: site.php

<?php   class site extends ci_controller {     function __construct()   {         // call model constructor         parent::__construct();   }    function index(){      $this->load->model('data_model');     $data['rows'] = $this->data_model->getall();      $this->load->view('home', $data);    } } 

always make sure extends model ci_model recognized .

 class model extends ci_model {   //you can put function construct      public function __construct (){       parent::__construct ();     } } 

in controller :

class sample extends ci_controller {   public function __construct () {      parent:: __construct();      //you can load here model load everytime use in function     $this->load->model('nameofmodel');    } } 

remember : name of model or controller must same filename.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -