How does Thinkphp query the database in batches?
天蓬老师
天蓬老师 2017-05-27 17:42:03
0
4
654

1. I have such a requirement: there are 4 kinds of inventory in the warehouse receipt. I want to check whether there is such inventory in the existing table. If there is, increase the quantity. If not, create new data; the where condition is an array. I should How to inquire?

2.where condition

Array
(
    [0] => Array
        (
            [warehouse] => 办公用品仓库
            [name] => 笔记本电脑
        )

    [1] => Array
        (
            [warehouse] => 办公用品仓库
            [name] => 笔记本电脑
        )

    [2] => Array
        (
            [warehouse] => 办公用品仓库
            [name] => 万用表
        )

    [3] => Array
        (
            [warehouse] => 办公用品仓库
            [name] => 鼠标
        )

)

3. Query statement, the following query is empty

$ch = $stock->where($where)->select();

I just learned it not long ago, and all the masters have provided me with some good ideas~~Thank you all

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
大家讲道理

where conditions:

    $where['warehouse'] = '办公用品仓库';
    $where['name'] = array('in', array('笔记本电脑','万用表','鼠标'));
仅有的幸福
// 去除 name 值,去重处理
$where['name'] = ['in', implode(',', array_unique(array_column( $data, 'name')))];
小葫芦

thinkphp 3.23?

$where['warehouse'] = '办公用品仓库';
$where['name'] = array('in', array('笔记本电脑','万用表','鼠标'));
//or
$where['warehouse'] = '办公用品仓库';
$where['name'] = array('in', '笔记本电脑,万用表,鼠标');

thinkphp 5.0?

where('warehouse','in','笔记本电脑,万用表,鼠标');
// or
where('warehouse','in',['笔记本电脑','万用表','鼠标']);
大家讲道理

Correct answer upstairs. . . . . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template