Skip to main content

Error Undefined property

April 28, 2011 by noeldejavu

noeldejavu's picture

Dear ci-er..

Akang-akang n teteh-teteh.
mohon bantuannya.. ane masih newbie neh.
ane pake CI 2.0.2, ketika diload muncul pesan error :

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Part::$Part
Filename: controllers/part.php
Line Number: 28

Berikut code CI yang ane buat :
Controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Part extends CI_Controller {
 
	 */
	public function index($offset = 1)
	{
		$perpage = 30;
 
		$config = array(
            'base_url' => base_url() . 'part/index/',
            'total_rows' => count($this->part->get_part()),
            'per_page' => $perpage
        );
 
		$this->pagination->initialize($config);
		$data['qpart'] = $this->Part_model->get_part(array('perpage' => $perpage, 'offset' => $offset));
 
		$this->load->view('part_list',$data);
	}
}

Model

<?php
 
class Part_model extends CI_Model {
 
	function __construct()
	{
		parent::__construct();
	}
 
	function get_part($limit = array())
    {
        $query = $this->db->get('part');
		if ($limit == NULL)
			return $this->db->get('part');
		else
		    return $this->db->limit($limit['perpage'], $limit['offset'])->get('part')->result();
    }
}
 
?>

View

<body>
 
<h1>PART LIST</h1>
 
<table>
  <tr>
    <td>No</td>
    <td>Part No</td>
    <td>Part Name</td>
    <td>Customer</td>
    <td>Model</td>
  </tr>
  <?php $i = 1 ?>
  <?php foreach ($qpart as $bt): ?>
  <tr>
    <td><?php echo $i++; ?></td>
    <td><?php echo $bt->nopart; ?></td>
    <td><?php echo $bt->partname; ?></td>
    <td><?php echo $bt->custid; ?></td>
    <td><?php echo $bt->model; ?></td>
  </tr>
  <?php  endforeach; ?>
</table>
<?php echo $this->pagination->create_links(); ?>
 
</body>

Kira-kira dari code-code diatas apa yach yang salah.. mohon bantuannya yach para master.

Terima kasih sebelumnya.

Comments

Comment viewing options

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

mungkin tu kurang

May 1, 2011 by juju, 2 days 39 min ago
Comment: 8085

juju's picture

mungkin tu kurang penulisan'a
yg sebner'a
'total_rows' => count($this->part_model->get_part())

sorry bro kl salah, ane g ngerti line number 28 tu yg mana :)

variabel

April 29, 2011 by kuringpisan, 4 days 14 hours ago
Comment: 8073

kuringpisan's picture

Error messagenya cukup jelas, kok, ada di controller Part, baris yang ini:
'total_rows' => count($this->part->get_part())
$this->part artinya masbro ingin mengakses fungsi atau variabel part dalam kelas Part, sementara variabel atau fungsi itu tidak ada, sepertinya masbro lupa mendefinisikan variabel part yang akan meload model Part_model.

CMIIW

Devinisikannya gmn gan? ga

May 2, 2011 by noeldejavu, 1 day 17 hours ago
Comment: 8090

noeldejavu's picture

Devinisikannya gmn gan?
ga mudeng neh?
hub antara variabel antara du view, model & controller..
bisa ngasih sample?

thanks

Premium Drupal Themes by Adaptivethemes