public function addChecklistItemRel($entity_type, $entity_id, $pc_id) { $modelPCdefault = ProcessChecklistDefault::model()->getPCheckListDefaultByCheckList($pc_id); $result = false; foreach ($modelPCdefault->data as $value) { $model = new ProcessChecklistItemRel(); $model->pcir_entity_type = $entity_type; $model->pcir_entity_id = $entity_id; $model->pc_id = $pc_id; $model->pcir_name = $value->pcdi_name; $model->pcir_order = $value->pcdi_order; $model->pcir_status_date = date('Y-m-d'); $model->pcir_status_update_by = 0; if ($model->save()) { $result = true; } } return $result; }