Hi all
i want to ask, i have table like this (dump from postgresql):
CREATE TABLE country (
country_code character varying(3) NOT NULL,
country_name character varying(30) NOT NULL
);
ALTER TABLE ONLY country
ADD CONSTRAINT country_country_name_key UNIQUE (country_name);
ALTER TABLE ONLY country
ADD CONSTRAINT country_pkey PRIMARY KEY (country_code);
i use CRUD to manage this table, first i having a problem at actionCreate:
$country->attributes=$_POST['Country'];
I don't know why '$country->attributes' only contain country_name use above command
so i use this way:
$country->country_code=$_POST['Country']['country_code'];
$country->country_name=$_POST['Country']['country_name'];
My first question how is the proper way to insert table with primary key.
Second i try to update this table, using the same method of insert, i got error:
The requested country does not exist.
I guess AR generate query like this:
UPDATE country SET country_code='new-code',country_name='country-name' WHERE country_code='new-code';
I think the condition should be country_code='old-code'
My question is how i set criteria when do update (using save() ??), or what is the right way to update? I don't want to change my table schema (add a autoincrement primary key)
thanks in advance