CodeIgniter Forums
problem with model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: problem with model (/showthread.php?tid=42527)



problem with model - El Forum - 06-09-2011

[eluser]dang2man[/eluser]
i have this code and when i tried to open it say

PHP Fatal error: Class 'Model' not found in C:\wamp\www\ci\application\models\mcat.php on line 2
<?php
class Mcat extends Model{

function __construct() {
parent::__construct();
}
function getCategory($id){
$data = array();
$options = array('id'=>$id);
$q = $this->db->getwhere('categories',$options,1);
if($q->num_row > 0){
$data = $q->row_array();
}
$Q-> free_result();
return $data;
}


function getAllCategories(){
$data = array();
$q = $this->db->get('categories');
if($q->num_row() > 0){
foreach ($q->result_array() as $rows){
$data = $rows;

}
$q = free_result();
return $data;
}

}

}


?>


i have added mcat in autoload.php


problem with model - El Forum - 06-09-2011

[eluser]danmontgomery[/eluser]
CI_Model, not Model.

http://ellislab.com/codeigniter/user-guide/general/models.html


problem with model - El Forum - 06-11-2011

[eluser]dang2man[/eluser]
thanks noctrum its working now

but why i must put ci before model?


problem with model - El Forum - 06-11-2011

[eluser]InsiteFX[/eluser]
Because the Blog your using was designed for CI 1.7.2 not CI 2.0.+

InsiteFX