我尝试修复了一个codeigniter应用程序。在模型中总是说:消息:试图获得非对象的属性
这是我的模特:
class Custom_lesson extends Domain_class
{
//private $customSftObj = null;
public $customSftObj = null;
public $custom_sft = null;
public function __construct()
{
parent::__construct();
}
public function getCustomSft()
{
if (FALSE == empty($this->customSftObj))
return $this->customSftObj;
$customSftDAO = $this->loadDAO('custom_sft');
$this->customSftObj = $customSftDAO->find($this->custom_sft);
return $this->customSftObj;
}
public function getSft() {
return $this->getCustomSft();
}
public function doDestroy()
{
$custom_sft = $this->getCustomSft();
if ( $this->hasSM() )
unlink( custom_sft_path($custom_sft->owner_id, $custom_sft->subject, $custom_sft->grade) . 'lessons/_lesson_' . $this->id . '_SM.pdf' );
if ( $this->hasTM() )
unlink( custom_sft_path($custom_sft->owner_id, $custom_sft->subject, $custom_sft->grade) . 'lessons/_lesson_' . $this->id . '_TM.pdf' );
}
public function hasSM()
{
$custom_sft = $this->getCustomSft();
return file_exists( custom_sft_path($custom_sft->owner_id, $custom_sft->subject, $custom_sft->grade) . 'lessons/_lesson_' . $this->id . '_SM.pdf');
}
public function hasTM()
{
$custom_sft = $this->getCustomSft();
return file_exists( custom_sft_path($custom_sft->owner_id, $custom_sft->subject, $custom_sft->grade) . 'lessons/_lesson_' . $this->id . '_TM.pdf');
}
这是我的自定义dao模型:
<?php
class Custom_lesson_DAO extends MY_Model
{
function Custom_lesson_DAO()
{
parent::__construct();
}
function getTableName()
{
return 'custom_table';
}
function findForSFT($custom_sft)
{
return $this->fetch( array('custom_sft' => $custom_sft->id, 'order_by' => 'listing_order ASC') );
}
function findForSFTLimitOffset($custom_sft, $limit, $offset)
{
return $this->fetch( array('custom_sft' => $custom_sft->id, 'limit' => $limit, 'offset' => $offset) );
}
function countForSFT($custom_sft)
{
return $this->count( array('custom_sft' => $custom_sft->id) );
}
protected function parseJoin($model)
{
if ($model == 'cts_lesson')
{
$CI =& get_instance();
$CI->load->model($model);
$this->db->join($CI->$model->getTableName(), 'cts_lessons.lesson = lessons.id', 'left');
}
else parent::parseJoin($model);
}
public function getMaxOrder()
{
$this->db->select('MAX(listing_order) as max');
$max = $this->db->get($this->getTableName())->row()->max;
return $max;
}
错误在第42和48行,实际上这些行是相同的函数custom_sft_path
事情是变量没有设置
return file_exists( custom_sft_path($custom_sft->owner_id, $custom_sft->subject, $custom_sft->grade) . 'lessons/_lesson_' . $this->id . '_SM.pdf');
变量总是空的,我不知道:
$custom_sft->owner_id, $custom_sft->subject,
我不知道为什么得到这个错误的帮助我。