A bulk add-in package,
$data is a two-dimensional array, key corresponding to the field name of the data table;
/**
* Batch Creation
* @param array $data
* @return int $res affect line
* @author Wen
*/
Public Function Createmore ($data)
{
Processing data gets the name of the field to add data to
$sql _key = NULL;
$data _key = Array_keys ($data [0]);
foreach ($data _key as $k _k = $k _v) {
$sql _key. = '. $k _v. ', ';
}
$sql _key = substr ($sql _key,0,-1);
Processing data gets the data to be added
$sql _value = NULL;
foreach ($data as $v _k = $v _v) {
$sql _value. = ' (';
$data _v_data = array_values ($v _v);
foreach ($data _v_data as $v _d_k = $v _d_v) {
$sql _value. = "'". $v _d_v. "',";
}
$sql _value = substr ($sql _value,0,-1);
$sql _value. = '), ';
}
$sql _value = substr ($sql _value,0,-1);
Assembling SQL
$sql = ' INSERT into '. $this->g_table;
$sql. = ' ('. $sql _key. ') ';
$sql. = ' VALUES '. $sql _value;
$res = $this->execute ($sql);
return $res;
}
MySQL Batch Add