Welcome Guest, Not a member yet? Register   Sign In
problem in search model
#1

[eluser]SamoualSys[/eluser]
hi i have made search model to search from the data base and show it in the view page but it show me error if the view page load my model code is
the error message is
Call to undefined method CI_Model::_construct() in C:\xampp\htdocs\bank\application\models\search_model.php on line 7
Code:
<?php

class Search_model extends CI_Model {

function Search_model()
{
parent::_construct();
}

function getSearchResults ($function_name, $description = TRUE)
{
  $this->db->like('function_name', $search);
  $this->db->orderby('function_name');
  $query = $this->db->get('functions');
  if ($query->num_rows() > 0) {
   $output = '<ul>';
   foreach ($query->result() as $function_info) {
    if ($description) {
     $output .= '<li><strong>' . $function_info->function_name . '</strong><br />';
     $output .= $function_info->function_description . '</li>';
    } else {
     $output .= '<li>' . $function_info->function_name . '</li>';
    }
   }
   $output .= '</ul>';
   return $output;
  } else {
   return '<p>Sorry, no results returned.</p>';
  }
}

}
?&gt;
if i remove the model from the auto load it show me different error
Call to a member function getSearchResults() on a non-object in C:\xampp\htdocs\bank\application\controllers\home.php on line 45
controllers code is
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Home extends CI_Controller {
  
  function __construct()
  {
    parent::__construct();
    
// $this->load->model('Search_model');
// $this->output->cache(120);
  }

  function index()
  {
    if($this->session->userdata('logged_in'))
    {
      $session_data = $this->session->userdata('logged_in');
      $data['user'] = $session_data['user'];
      $this->load->view('home_view', $data);
    }
    else
    {
      //If no session, redirect to login page
      redirect('login', 'refresh');
    }
  }
  
  function logout()
  {
    $this->session->unset_userdata('logged_in');
    session_destroy();
    redirect('home', 'refresh');
  }
  function ajaxsearch()
{
  $function_name = $this->input->post('function_name');
  $description = $this->input->post('description');
  echo $this->function_model->getSearchResults($function_name, $description);
}

function search()
{
  $data['title'] = "نظام البحث الألكتروني";
  $uni_name = $this->input->post('uni_name');
  $data['search_results'] = $this->Search_model->getSearchResults($uni_name);
  $this->load->view('home/search', $data);
}
  
}
  
?&gt;
i hope someone can help me




Theme © iAndrew 2016 - Forum software by © MyBB