$val = implode(',', array_fill(0, count([$a,$a,$a,$a]), '?'));
$keys = ['1','2','3','4'];
/*
* @return string $table 表名
* @return array $keys 字段
* @return array $value 数据
* @return string $val 占位
* 添加
* */
public function Insert($table = '',$keys = [],$values = [],$val = ''){
try{
if (empty($values) or $val == ''){
return;
}
$sql = $this->pdo->prepare("insert into $table (".implode(',',$keys).") values $val");
$this->pdo->beginTransaction();
foreach($values as &$row) {
$sql->execute($row);
}
$this->pdo->commit();
}catch (Exception $e){
//加入log
file_put_contents('./swoole.log', '[' . date('Y-m-d H:i:s') . ']' . var_export($e->getMessage(),true) . PHP_EOL,FILE_APPEND);
return false;
}
}