![]() |
HI i have this model :
Code: protected $allowedFields = ['id','id_categoria_lavorazione','nome','codice','menu_linea_implantare','scala_colori','numero_dente','quantita_elementi','prezzo_vendita_da_file','gg_lavorativi','created_at','updated_at','deleted_at']; scala_colori is type json in db this is the $post variable from form: Code: Array ( [id_categoria_lavorazione] => 32 [nome] => test [codice] => DM4CCSX [menu_linea_implantare] => SI [scala_colori] => Array ( [0] => 37 [1] => 39 [2] => 19 [3] => 3 ) [numero_dente] => 10 [quantita_elementi] => 15 [prezzo_vendita_da_file] => 20 [gg_lavorativi] => 1 ) i simpli do this is my error : $descrizione_lavorazione_model->save($post); Operand should contain 1 column(s) How can i insert the array into json field ? SOLVED: Code: $post['scala_colori'] = json_encode($post['scala_colori']);
You should never put the $post or $get arrays into a database it's a security problem waiting to happen.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Because SQL code injection could be inserted into the $post or $get array and then executed.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
First check your $post or $get array to make sure it has the right data ( Never trust user input )
PHP How to INSERT a JSON object/array in a MySQLi Database What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-06-2022, 12:20 AM)InsiteFX Wrote: First check your $post or $get array to make sure it has the right data ( Never trust user input ) i check first with validate... |
Welcome Guest, Not a member yet? Register Sign In |