D
D
des1roer2015-07-03 17:53:40
Yii
des1roer, 2015-07-03 17:53:40

Yii 1.* + Postgres not working $model->id in actionCreate?

can't use $model->id in actionCreate. default gii settings. Is this a bug or am I just not good at cooking?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oRx0r, 2015-07-05
@oRx0r

Perhaps AR couldn't guess the name of the sequencer for the id field in the plate.
Try to re-create the table with serial pseudo-type:
CREATE TABLE foo
(
id serial NOT NULL,
...
);
Or like this (if you don't want to lose data in the table):
CREATE SEQUENCE foo_id_seq;
ALTER TABLE foo ALTER COLUMN id SET DEFAULT nextval('foo_id_seq'::regclass);
ALTER TABLE foo ALTER COLUMN id SET NOT NULL;
ALTER SEQUENCE foo_id_seq OWNED BY foo.id;
SELECT setval('foo_id_seq', MAX(id)) from foo;
After that, switching the sequencer in the trigger can be removed, since it will switch automatically when inserting records.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question