ci database library doesn't allow mulitple line sql statements??? |
[eluser]diez[/eluser]
For some reason i can't run this query. I get a CI database error running it through CI, however when i run the exact same query through phpMyAdmin it executes fine. $str_sql = "INSERT INTO customers VALUES('', 'fred', 'barney', '[email protected]'); INSERT INTO customers VALUES('', 'fred', 'barney', '[email protected]');" if($this->db->query($str_sql)) { return true; } return false; However, if i take out on the insert statements lines the query runs fine through CI. ...?? any help?
[eluser]xwero[/eluser]
multiple inserts can be written as INSERT INTO customers VALUES(’’, ‘fred’, ‘barney’, ‘[email protected]’),(’’, ‘fred’, ‘barney’, ‘[email protected]’) All database functions are based on php native functions and the mysql_query function documentation shows Quote:multiple queries are not supportedIf you want to use multiple queries you will have to write your own method for it.
[eluser]adamp1[/eluser]
All I do for multiple queries, say for installation of my app is have a scheme file and my php code parses the file exploding it about the ; on the end of the line. Then just loop through. I don't know if you are trying to run these commands from a file or not, but if you are there's a easy solution for you. |
Welcome Guest, Not a member yet? Register Sign In |