mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02: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');
|
$bind = $this->connection->getTableInfo($options['table'], 'bind');
|
||||||
$fields = array_keys($bind);
|
if ('*' == $options['field']) {
|
||||||
|
$fields = array_keys($bind);
|
||||||
|
} else {
|
||||||
|
$fields = is_array($options['field']) ? $options['field'] : explode(',', $options['field']);
|
||||||
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
if (!in_array($key, $fields, true)) {
|
if (!in_array($key, $fields, true)) {
|
||||||
@@ -543,8 +548,13 @@ abstract class Builder
|
|||||||
*/
|
*/
|
||||||
public function insertAll($dataSet, $options)
|
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 ($dataSet as &$data) {
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
if (!in_array($key, $fields, true)) {
|
if (!in_array($key, $fields, true)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user