/** * Save a request * * @param object RequestsModel object * * @return bool true or false if request has been saved */ public function saveRequest(Placid_RequestsModel &$model) { // Determine whether this is an existing request or if we need to create a new one // -------------------------------------------------------------------------------- if ($id = $model->getAttribute('id')) { $record = $this->record->findByPk($id); } else { $record = new Placid_RequestsRecord(); } // Get the attributes from the passed model $attributes = $model->getAttributes(); // Set the new attributes to the record $record->setAttributes($attributes, false); // Save the new request // ----------------------------------------------------------------------------- if ($record->save()) { $model->setAttribute('id', $record->getAttribute('id')); return true; } else { $model->addErrors($record->getErrors()); return false; } }
public function getRequestById($id) { if ($record = Placid_RequestsRecord::model()->findByPk($id)) { return Placid_RequestsModel::populateModel($record); } return null; }