gpt4 book ai didi

php - Laravel 'whereNotIn' 查询难度

转载 作者:行者123 更新时间:2023-12-01 22:50:27 31 4
gpt4 key购买 nike

我正在尝试运行以下查询并遇到此错误:

preg_replace(): Parameter mismatch, pattern is a string while replacement is an array

当我删除“whereNotIn”部分时,查询有效。我知道第一个查询有效,因为我单独对其进行了测试。我该如何解决这个错误?这是代码:

$alreadyCheckedOutDevicesQuery = DB::connection('NEWSTAFFPORTAL')->table('DeviceCheckout_checkout')->select('deviceID')->where('inBy', '=', '')->get();

$alreadyCheckedOutDevices = GlobalModel::convertDBObjectsToArray($alreadyCheckedOutDevicesQuery);

$deviceTableInformation = DB::connection('NEWSTAFFPORTAL')->table('DeviceCheckout_deviceListTestingTable')->select('deviceID', 'name', 'type', 'brand', 'model')->whereNotIn('deviceID', $alreadyCheckedOutDevices)->orderBy('name', 'ASC')->get();

最佳答案

尝试在子查询中进行:

$info = DB::connection('NEWSTAFFPORTAL')
->table('DeviceCheckout_deviceListTestingTable')
->select('deviceID', 'name', 'type', 'brand', 'model')
->orderBy('name', 'asc')
->whereNotIn('deviceID', function ($query)
{
$query->from('DeviceCheckout_checkout')
->select('deviceID')
->where('inBy', '');
})
->get();

关于php - Laravel 'whereNotIn' 查询难度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25251879/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com