本文整理汇总了PHP中CI_Model::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_Model::save方法的具体用法?PHP CI_Model::save怎么用?PHP CI_Model::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI_Model
的用法示例。
在下文中一共展示了CI_Model::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save(&$person_data, &$employee_data, &$grants_data, $employee_id = false)
{
$success = false;
//Run these queries as a transaction, we want to make sure we do all or nothing
$this->db->trans_start();
if (parent::save($person_data, $employee_id)) {
if (!$employee_id or !$this->exists($employee_id)) {
$employee_data['person_id'] = $employee_id = $person_data['person_id'];
$success = $this->db->insert('employees', $employee_data);
} else {
$this->db->where('person_id', $employee_id);
$success = $this->db->update('employees', $employee_data);
}
//We have either inserted or updated a new employee, now lets set permissions.
if ($success) {
//First lets clear out any grants the employee currently has.
$success = $this->db->delete('grants', array('person_id' => $employee_id));
//Now insert the new grants
if ($success) {
foreach ($grants_data as $permission_id) {
$success = $this->db->insert('grants', array('permission_id' => $permission_id, 'person_id' => $employee_id));
}
}
}
}
$this->db->trans_complete();
return $success;
}
示例2: save
function save(&$person_data, &$supplier_data, $supplier_id = false)
{
$success = false;
//Run these queries as a transaction, we want to make sure we do all or nothing
$this->db->trans_start();
if (parent::save($person_data, $supplier_id)) {
if (!$supplier_id or !$this->exists($supplier_id)) {
$supplier_data['person_id'] = $person_data['person_id'];
$success = $this->db->insert('suppliers', $supplier_data);
} else {
$this->db->where('person_id', $supplier_id);
$success = $this->db->update('suppliers', $supplier_data);
}
}
$this->db->trans_complete();
return $success;
}