小编dev*_*ius的帖子

使用 fnmatch() 匹配多个文件扩展名

在典型的文件匹配代码中:

while (false !== ($file = readdir($handle))) {
    if ($file !== "." && $file !== ".." && fnmatch($mask, $file)) {
        $dirList[] = $file;
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图使用这样的多文件扩展名模式:

$mask = "*.{jpg,png,gif}";
Run Code Online (Sandbox Code Playgroud)

但它不起作用。没有文件匹配。这很奇怪,因为相同的模式在终端中工作得很好。它也可以与 glob() 完美配合,返回我想要的文件。我知道其余代码没有任何问题,因为使用“*.jpg”作为掩码也适用于 fnmatch。难道 fnmatch 不应该支持 shell 中可用的相同模式吗?

php

4
推荐指数
1
解决办法
3093
查看次数

knex.raw.query() 给出 ORDER BY 绑定错误

我通过以下方式绑定到 knex 原始查询来添加订单。

-- Here userIds = [1,2,3] and dataOrder='DESC'

knex.raw.query("
 select from users
 where userId in ?
 order by created ?
",
[
 userIds,
 dataOrder
])
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息

check the manual that corresponds to your MySQL server version for the right syntax 
to use near ''DESC'' at line 1
Run Code Online (Sandbox Code Playgroud)

我尝试使用单引号和双引号的dataOrder 。

knex.js

3
推荐指数
1
解决办法
2118
查看次数

标签 统计

knex.js ×1

php ×1