mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
insert和update方法支持使用field方法过滤写入字段
This commit is contained in:
@@ -69,8 +69,13 @@ abstract class Builder
|
||||
}
|
||||
|
||||
// 获取绑定信息
|
||||
$bind = $this->connection->getTableInfo($options['table'], 'bind');
|
||||
$fields = array_keys($bind);
|
||||
$bind = $this->connection->getTableInfo($options['table'], 'bind');
|
||||
if ('*' == $options['field']) {
|
||||
$fields = array_keys($bind);
|
||||
} else {
|
||||
$fields = is_array($options['field']) ? $options['field'] : explode(',', $options['field']);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $fields, true)) {
|
||||
@@ -543,8 +548,13 @@ abstract class Builder
|
||||
*/
|
||||
public function insertAll($dataSet, $options)
|
||||
{
|
||||
// 获取绑定信息
|
||||
$fields = $this->connection->getTableInfo($options['table'], 'fields');
|
||||
// 获取合法的字段
|
||||
if ('*' == $options['field']) {
|
||||
$fields = $this->connection->getTableInfo($options['table'], 'fields');
|
||||
} else {
|
||||
$fields = is_array($options['field']) ? $options['field'] : explode(',', $options['field']);
|
||||
}
|
||||
|
||||
foreach ($dataSet as &$data) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $fields, true)) {
|
||||
|
||||
Reference in New Issue
Block a user