0

hey guys i'm using PHP's codeigniter to create my application and postgreSQL as database and i have to update some value in database. So, let's say we have table structure like this:-

CREATE TABLE emailrecord (
   id serial NOT NULL,
   email json 
);

insert first record

INSERT INTO emailrecord (email) VALUES('{"id":"abc@any.com"}');

Now, how to update the inserted record at 1 which is to be like this

'{{"id":"abc@any.com"},{"id","def@any.com"}}'

AND

is there any way to update it via CODEIGNITER it would be helpful for me

  • Why are you using JSON for this field? – Colin 't Hart May 15 '14 at 12:41
  • because it is just a example but i have to add many key value pair in it, different keys and different values – vishal May 15 '14 at 12:54
  • IMO, you should be putting each unique email in separate rows and you are duplicating id twice, when you use json, if you still want multiple values array is a better approach. OTH unique values will make updating/deleting easier. and just a thought json (in this case) will also increase your "autovaccum overheads". – vedic Jun 7 '14 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.