当前位置: 首页>>代码示例>>PHP>>正文


PHP CI_Model::save方法代码示例

本文整理汇总了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;
 }
开发者ID:SofyanHadiA,项目名称:rinjani-framework,代码行数:28,代码来源:employee.php

示例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;
 }
开发者ID:SofyanHadiA,项目名称:rinjani-framework,代码行数:17,代码来源:supplier.php


注:本文中的CI_Model::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。