CodeIgniter Forums
Insert return false but inserts succesfully - 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: Insert return false but inserts succesfully (/showthread.php?tid=79909)



Insert return false but inserts succesfully - BFlokstra - 08-13-2021

I'm wreaking my brain, unable to figure this one out. 
I have the folowing code:
PHP Code:
if ($klantenModel->insert([
                        'id' => $this->request->getPost('id'),
                        'naam' => $this->request->getPost('naam'),
                        'woonplaats' => $this->request->getPost('woonplaats')
                    ]))
                {
                    return redirect()->to($_ENV['app.baseURL'] . 'klanten')->with('success''Gelukt.');
                }
                return redirect()->to($_ENV['app.baseURL'] . 'klanten')->with('error''Fout.'); 

What happens is dat the insert does what I expect (it inserts the data without a glitch), yet it returns false. And I can't figure out why. It doesn't insert empty columns, the data types of the respective columns in the database are correct (int for id and varchar(100) for the others). 

I hope you guys can help me figure out what the cause of this behavior is.


RE: Insert return false but inserts succesfully - InsiteFX - 08-13-2021

Try thios and see what your query is looking like.
PHP Code:
$db->insertID();
$db->getLastQuery(); 

Please show it here.