I still with this error in 2.0.10, does anybody know any solution?
is the same as here, but they did not gave solution https://forum.phalcon.io/discussion/6230/$obj%3Esave-==-false-return-serial-is-required#C30269
environment, php 5.6, postgresql 9.5
CREATE TABLE events (
id SERIAL not null,
"name" varchar(100) NOT NULL,
CONSTRAINT events_pkey PRIMARY KEY (id)
)
My sequence is really created:
# select nextval('events_id_seq'::regclass);
nextval
---------
2
(1 row)
my post
POST /api/v1/events HTTP/1.1
Host: docker
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 72e91b3e-e841-623a-f668-4bb6db2bcf53
{
"name": "Douglas"
}
Model
class Events extends ModelBase
{
public $id;
public $name;
}
Controller
function createAction() {
$event = new Events();
$post = $this->request->getJsonRawBody();
$event->name = $post->name;
if ($event->save() == false) {
/** @var Message $message */
foreach ($event->getMessages() as $message) {
$errors[$message->getField()] = $message->getMessage();
}
return $errors;
}
return $event->toArray();
}
output
{
"id": "id is required"
}