Update instead insert |
HI i have two model :
User : protected $allowedFields = ['id','email','password','user_activation_hash','id_stato_users','pin','tipo_utente','refertatore','sconto','updated_at','last_login']; protected $allowedFields = ['id_user','nome','cognome','data_nascita','telefono','nome_studio','numero_iscrizione_ordine','anno_iscrizione_ordine','piva','id_comuni','indirizzo','civico','cap','pec','sdi','note','normativa_ministero_salute','termini','privacy','comunicazioni']; this is a part of controller's method : Code: if($this->validate($rules)){ this is the log : Code: INFO - 2021-01-28 19:26:52 --> CSRF cookie sent why don't insert but update ?
Hi
I dont kknows why, but you can read : https://codeigniter.com/user_guide/model...light=save Its about $id
(01-28-2021, 01:32 PM)neoneeco Wrote: Hichange to insert instead save , the record are inserted but return false , why ? can i use transaction on model->save() and model->insert?
If the $id is in the database table it will do an update, if not it will do an insert.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I have tried to organize your coding a bit and asked you a question within the code area below. Could you please check?
PHP Code: if($this->validate($rules)){
(01-29-2021, 04:50 AM)demyr Wrote: I have tried to organize your coding a bit and asked you a question within the code area below. Could you please check? i save data for different model because i have a two type of user , the first part (a simple registration data) i save into a table users , the second part is specific of the type of user and i save it in the specific table (01-29-2021, 05:05 AM)pippuccio76 Wrote: i save data for different model because i have a two type of user , the first part (a simple registration data) i save into a table users , the second part is specific of the type of user and i save it in the specific table I asked because I wanted to be sure if you have the same columns in your second table? Btw, did you set auto increment for ID in your db table?
(01-29-2021, 05:19 AM)demyr Wrote:(01-29-2021, 05:05 AM)pippuccio76 Wrote: i save data for different model because i have a two type of user , the first part (a simple registration data) i save into a table users , the second part is specific of the type of user and i save it in the specific table I have id in user autoincrement , in dentisti i have id_user (foreign key of user ) without id |
Welcome Guest, Not a member yet? Register Sign In |