CodeIgniter Forums
SIngle quote on model save - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: SIngle quote on model save (/showthread.php?tid=90842)



SIngle quote on model save - pippuccio76 - 05-13-2024

Hi this is a simple part of my code :

Code:
                $post = $this->request->getPost();


                $res=$users_model->save($post);
I have some surname with singol quote and in db is not inserted the part after single quote , why ?


RE: SIngle quote on model save - JustJohnQ - 05-13-2024

There might be better solutions, but one is to escape the surname string before saving it:
Code:
$post['surname'] = $this->db->escape($post['surname']);



RE: SIngle quote on model save - kenjis - 05-13-2024

@pippuccio76 Your code should work. Did you override the save() method?


RE: SIngle quote on model save - pippuccio76 - 05-13-2024

(05-13-2024, 06:54 PM)kenjis Wrote: @pippuccio76 Your code should work. Did you override the save() method?

no i don't override , data are saved but singol quote truncate post data


RE: SIngle quote on model save - kenjis - 05-13-2024

Check the actual SQL statement.
See https://codeigniter4.github.io/CodeIgniter4/testing/debugging.html#logging-all-sql-queries