![]() |
Pass Array to Prepared Statements - 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: Pass Array to Prepared Statements (/showthread.php?tid=76680) |
Pass Array to Prepared Statements - 68thorby68 - 06-09-2020 Hi , I'm tearing my hair out trying to fathom Prepared statements in Ci4 as per the documentation. Could someone please help me understand why the follwing statement fails with error "mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement" undefined, when an array is passed to the execute statement, as per the documentation. I have tried enclosing the SQL ? parameter with parentheses (?) but get the same error????? This throws the error PHP Code: use CodeIgniter\Model; PHP Code: use CodeIgniter\Model; I just dont understand???? PLEASE HELP !!!!! RE: Pass Array to Prepared Statements - 68thorby68 - 06-16-2020 I DO NOT believe Ci4 execute accepts arrays of data, but instead insists on each data element being defined indiviually. That said I believe a single data field can be an array. Unfortunately this thread is a result of my mis-interpretation of the documentation. RE: Pass Array to Prepared Statements - israes - 01-28-2022 I'm dealing with it now, and thanks to your post my code now works!!! In addition, I found a quick fix related to this on php docs, take a look at example #5 https://www.php.net/manual/en/pdostatement.execute.php#example-1045 |