public function create($data = null, $whiteList = null) { if ($result = parent::create($data, $whiteList)) { return $result; } else { foreach ($this->getMessages() as $message) { echo $message->getMessage(); } return $result; } }
/** * Save/Create/Update an object * * @param \Phalcon\Mvc\Model $object * @param string $type * @throws \Exception * @return Object */ public function save($object, $type = 'save') { switch ($type) { case 'save': $result = $object->save(); break; case 'create': $result = $object->create(); break; case 'update': $result = $object->update(); break; } if (false === $result) { foreach ($object->getMessages() as $message) { $error[] = (string) $message; } $output = count($error) > 1 ? json_encode($error) : $error[0]; throw new \Exception($output); } return $object; }