gpt4 book ai didi

php - Medoo MySQL 不读取变量

转载 作者:行者123 更新时间:2023-11-29 11:38:12 25 4
gpt4 key购买 nike

我正在使用 Medoo MySQL 框架,但在 WHERE 语句中使用 IN 时遇到了这个问题:

$test = '1,2,3,4';

$count = $database->count("products", [
"AND" => [
"category_id" => $category['id'],
"id" => [$test]
]
]);

计数结果应该是 4,但我得到 1。但是:

$count = $database->count("products", [
"AND" => [
"category_id" => $category['id'],
"id" => [1,2,3,4]
]
]);

给了我 4 的正确结果。有什么想法吗?提前致谢!

最佳答案

试试这个...

$test = array(1,2,3,4);

$count = $database->count("products", [
"AND" => [
"category_id" => $category['id'],
"id" => $test // variable without []
]
]);

关于php - Medoo MySQL 不读取变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36276088/

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