public function updateOrderPeopleFor($model, $person_id, $type) { $rtn = false; $order_id = $model->id; $condition = 'order_id=' . $order_id; $condition .= ' AND LCASE(type) = "' . strtolower($type) . '"'; $criteria = new CDbCriteria; $criteria->condition = $condition; $result = Orderperson::model()->findAll( $criteria ); if(count($result)>0) { if(strtolower($type) === strtolower(Helper::CONST_Created)) return true; $record = $result[0]; } else { $record = new Orderperson; } if(empty($person_id) && !empty($record->id)) { $rtn = $record->delete(); } else { $record->order_id = $order_id; $record->person_id = $person_id; $record->type = $type; $rtn = $record->save(); } return $rtn; }