$obj->save() == false return "serial is required"


i have simply code:


> CREATE TABLE comments

> (

> id serial NOT NULL,

> owner integer,

> type character(1),

> created timestamp without time zone,

> message text,

> CONSTRAINT comments_pkey PRIMARY KEY (id)
> )

model is autogenerated and Controller:

> $comment= new Comments();

> $comment->message=$msg;

> $comment->owner=$uid;

> $comment->type=$type;

> $comment->created=date('Y-m-d h:i:s.u');


> if ($comment->save() == false) {


>     foreach ($comment->getMessages() as $value) {

>         echo $value.'; \n';

>     }

> }

return this: id is required

someone know why? other saves to tables work fine...

using Phalcon DevTools (1.3.4)

Ok im had the same error, occur when you have two columns of serial type or when you have two default value column with some sequence added, also you set null to id, ex: $comment->id = null;


ok, but i have only one autoincremented column... nothing else... simpliest from simpliest :P

edited Mar '15

Check if this serial was created sequence, something like php comment_id_seq and this seq and if really increment it value, also verify the column id if was add default value something like:



thank for replay. Actualy i havent access to DB, i check afternoon.

Yes, i using PgAdmin, why?