public function insertAll($datas, $options = array(), $replace = false)
{
if (!is_array(reset($datas))) {
return false;
}
$fields = array_keys($datas[0]);
array_walk($fields, array($this, 'parseKey'));
$values = array();
foreach ($datas as $data) {
$value = array();
foreach ($data as $key => $val) {
$val = $this->parseValue($val);
if (is_scalar($val)) {
// 过滤非标量数据
$value[] = $val;
}
}
$values[] = '(' . implode(',', $value) . ')';
}
$sql = ($replace ? 'REPLACE' : 'INSERT') . ' INTO ' . $this->parseTable($options['table']) . ' (' . implode(',', $fields) . ') VALUES ' . implode(',', $values);
return $this->execute($sql);
}