[eluser]Nidheesh[/eluser]
Hello am new in codeignitor .When i created my sample application the model was not detecting on my application
Controller Code
Code:
<?
class Testimonials extends CI_Controller {
/*function __construct()
{
parent::__construct();
// $this->load->model('Testimonials_model','',TRUE);
}*/
function _construct()
{
parent::__construct();
$this->load->model('Testimonials_model',"",TRUE);
}
function Testimonials()
{
$this->data['Page_Info']=$this->Testimonials_model->getmenus();
$this->load->view('Testimonials.php', $this->data);
echo $this->data['Page_Info'];
echo "babababa";
}
}
?>
Model Code
Code:
<?php
class Testimonials_model extends CI_Model{
public $id;
public $menuname='';
public $menulink='';
function Testimonials()
{
parent::__construct();
}
function getmenus()
{
$this->db->select('menu_Name,menu_link');
$this->db->from('tbl_menus');
$Page_Info=$this->db->get()->result();
return $Page_Info;
echo $Page_Info;
}
}
?>
View
Code:
<!DOCTYPE HTML>
<head>
<meta http-equiv="content-type" c />
<meta name="author" c />
<title>Title</title>
</head>
[removed]
$(document).ready(function(){
$('.goToAgentProfile').click(function(){
$('#sideBarForm').submit();
return false;
})
})
[removed]
<body>
<h1>Content From Controller</h1>
<h3>My Todo List</h3>
<?
if(isset($Page_Info) && is_array($Page_Info))
{
foreach($Page_Info as $key => $val)
{
$key = $val;
}
}
?>
<?
//print_r($Page_Data);
foreach($Page_Info as $row)
{
?>
<div blueviolet;">
<ul>
<li><a href="http://www.facebook.com"><?echo $row->id;?></a></li>
<li><?echo $row->menuname;?></li>
<li><?echo $row->menulink;?></li>
</ul>
</div>
<?}
?>
</body>
</html>
Error
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Testimonials::$testimonials_model
Filename: controllers/Testimonials.php
Line Number: 19
( ! ) Fatal error: Call to a member function getmenus() on a non-object in D:\wamp\www\samplesite\application\controllers\Testimonials.php on line 19
Call Stack
# Time Memory Function Location
1 0.0000 149768 {main}( ) ..\index.php:0
2 0.0000 185880 require_once( 'D:\wamp\www\samplesite\system\core\CodeIgniter.php' ) ..\index.php:202
3 0.0469 659008 Testimonials->Testimonials( ) ..\CodeIgniter.php:308