我不想从我想使用的模型__get
和__set
我的模型中更新每列的 getter 和 setter,但它不起作用。
这是一个例子:
class Video extends CI_Model {
private $video_id = null;
private $title;
private $url;
private $thumb;
private $width;
private $height;
public function __set($name, $value){
if(!$this->video_id) return false;
if(property_exists($this, $name))
{
$data = array(
$name => trim($this->security->xss_clean($value)),
'updated' => date('Y-m-d H:i:s'),
);
if($this->db->update('users', $data, array('video_id' => (int)$this->video_id)))
{
return $this->db->affected_rows();
}
else
{
return $this->db->_error_message();
}
}
}
}
然后从我的控制器我做:
$this->video->width(780);
产生:
<b>Fatal error</b>: Call to undefined method Video::width() in <b>/home/crazy/public_html/dev/application/controllers/admin.php</b> on line <b>169</b><br />