A software upgrade will be done recently , It involves the changes of database table fields ( Add or delete or modify ), All about database changes sql Statements are stored in Sqlupdate.sql In the file , Each upgrade needs to be performed once Sqlupdate.sql Everything in the sql sentence , This involves the problem of executing multiple statements . Software in CodeIgniter Developed on the framework ,CodeIgniter Encapsulated execution sql Function of statement :$this->db->query('****'), However, this function can only execute one at a time sql sentence . So we have to find another way . Baidu , Found some information .multi_query() The method is completely in accordance with sql Statement execution in environment , So you can execute more than one at a time sql sentence ( Press sql Grammar spelling , Each statement starts with ; end ).

$mysqli = new
mysqli($this->db->hostname,$this->db->username,$this->db->password,$this->db->database);
// connect MySQL database

if ($mysqli->connect_errno) { // Judge whether the connection is successful printf("Connect failed: %s\n",
$mysqli->connect_error);exit();

}$mysqli->multi_query($dataStr); // implement sql sentence

The following are Baidu's references :

use mysqli Object query() Method can only execute one at a time SQL command . If you need to execute more than one at a time SQL command , You must use mysqli Object
multi_query() method . The specific approach is to put multiple SQL The command is written in the same string and passed to the user as an argument multi_query() method , Multiple SQL Use semicolons between
(;) separate . If article 1 SQL There was no error in the execution of the command , This method will return TRUE

Technology