【发布时间】:2011-06-02 14:26:26
【问题描述】:
我有一个具有此功能的 SectorModel:
public function update(Sector $sector) {
$this->db->where('sector_id', $sector->getScetor_id());
return $this->db->update(_SECTOR_, $sector);
}
有时我只会更改 Sector 对象的名称:
$Sector = new Sector();
$Sector->setSector_name = 'test';
$this->SectorModel->update($Sector);
生成的选择看起来像:
UPDATE realestate_sector SET sector_name = 'teste', sector_description = NULL
它将更新,但会将所有其他属性设置为 NULL,因为它没有在我的对象上设置。 现在,我必须在发送之前填充整个对象。
有没有办法映射 Sector 类并仅更新对象上发送的内容?
提前感谢您的帮助。
抱歉有错别字,我的英文不好=)
【问题讨论】:
-
你可以取消设置 NULL 属性
标签: php database codeigniter frameworks model