Skip to main content

class not found

April 13, 2011 by hery_yud

hery_yud's picture

selamat pagi agan2
saya punya script d bawah nih yang menjelaskan penambahan produck.trus ketika saya accsess muncul class not found."Fatal error: Class 'Model' not found in C:\xampp\htdocs\CI\application\models\product_model.php on line 2"itu knp ya.tolong di bantu ya kakak2 master CI.terima kasih....

produck.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class product extends CI_Controller {
 
	function __construct()
	{
		parent::__construct();
		//This->view_data['base_url']=base_url();
		$this->load->model('product_model');
		$this->load->helper('html');
	}
 
	function index()
	{
		$data['query']=$this->db->get('produk');
		$data['title']='Internusa Soccer';
		$data['add_product'] = anchor('product/add_product','<< Tambah Produk');
		$data['middle']='product/product_view';
		$this->load->view('tamplate',$data);
	}
 
	function add_product()
	{
	   $data['title'] = 'Internusa Soccer';
	   $data['middle'] = 'product/form_brg';
	   $data['form_action'] = 'product/add_member_process';
	   $this->load->view('tamplate',$data);
	}
	function add_product_process()
	{
	   $data['title'] = 'Internusa Soccer';
	   $data['middle'] = 'product/form_product';
	   $data['form_action'] = 'product/add_member_process';
	   $this->load->view('tamplate',$data);
	   if($this->form_validation()==TRUE)
	   {
		if($this->barang_validation($kode_brg)!= true)
		{
			$data=array('id_barang'=>$this->input->post('kode_brg'),
						'id_kategori'=>$this->input->post('kode_ktgri'),
						'id_induk_barang'=>$this->input->post('kode_indk_brg'),
						'nama_barang'=>$this->input->post('nama_brg'));
			$this->product_model->insert($data);
 
		}
	   }
	}
 
	function form_validation()
	{
		$this->form_validation->set_rules('kode_brg','kode barang','required|min_length[5]');
 
		if($this->form_validation->run()==true)
			return true;
		else
			return false;
	}
 
	function barang_validation($kode_brg)
	{
		if($this->product_model->check_barang($kode_brg)==TRUE)
			return true;
		else
			return false;
	}
}

product_model.php

<?php
class Product_model extends Model{
 
	function Product_model()
	{
	   parent::Model();
	}
 
	var $table = 'produk';
	function get()
	{
	  return $this->db->get($this->table)->result();
	}
 
function insert($data)
	{
		$this->db->insert($this->table,$data);
	}
 
	function check_barang($kode_brg)
	{
		$query=$this->db->get_where($this->table,array('id_brg'=>$kode_brg),1,0);
 
		if($query->num_rows>0)
			return true;
		else
			return false;
	}
}
?>

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

function Product_model() {

April 14, 2011 by develop_php, 1 day 5 hours ago
Comment: 8007

develop_php's picture

function Product_model()
{
parent::Model();
}

ganti

function __construct()
{
// Call the Model constructor
parent::__construct();
}

thanks

April 15, 2011 by hery_yud, 1 day 2 hours ago
Comment: 8009

hery_yud's picture

terima kasih kak.sdh bs skrg

gini dong anda kurang class

April 13, 2011 by develop_php, 2 days 5 hours ago
Comment: 7996

develop_php's picture

gini dong anda kurang

class Product_model extends CI_Model

msh gak bs kk

April 14, 2011 by hery_yud, 1 day 7 hours ago
Comment: 8006

hery_yud's picture

muncul begini
Fatal error: Call to undefined method CI_Model::Model() in C:\xampp\htdocs\CI\application\models\product_model.php on line 6

Premium Drupal Themes by Adaptivethemes