• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model is not detecting

#1
[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>
&lt;head&gt;
&lt;meta http-equiv="content-type" c /&gt;
&lt;meta name="author" c /&gt;

&lt;title&gt;Title&lt;/title&gt;
&lt;/head&gt;
[removed]
$(document).ready(function(){
$('.goToAgentProfile').click(function(){
  $('#sideBarForm').submit();
  return false;
})
})    
[removed]

&lt;body&gt;

<h1>Content From Controller</h1>

<h3>My Todo List</h3>


&lt;?
if(isset($Page_Info) && is_array($Page_Info))
{
foreach($Page_Info as $key => $val)
{
  $key = $val;
}
}
?&gt;
&lt;?
//print_r($Page_Data);
foreach($Page_Info as $row)
{
    ?&gt;
    <div  blueviolet;">
    <ul>
   <li><a href="http://www.facebook.com">&lt;?echo $row->id;?&gt;</a></li>
    <li>&lt;?echo $row->menuname;?&gt;</li>
    <li>&lt;?echo $row->menulink;?&gt;</li>
    
    </ul>
    </div>
  
    
&lt;?}
?&gt;

&lt;/body&gt;
&lt;/html&gt;



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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.