php - 使用 id 参数查询返回错误记录

标签 php mysql laravel query-builder

当我运行查询从数据库检索记录时,我传递了 id 参数,但它返回了错误的记录:

使用此查询:

    $idusers = \DB::table('users')
            ->select('users.*')
            ->where('id','=', $id)
            ->get();

我传递id = 91TDFS78,结果实际上是用id = 91记录的。

最佳答案

谢谢大家,我必须在运行查询之前进行测试

$isdigit = ctype_digit((string)$id);
if($isdigit){
$idusers = \DB::table('users')
            ->select('users.*')
            ->where('id','=', $id)
            ->get();
}

关于php - 使用 id 参数查询返回错误记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42485913/

相关文章:

php - 将调试输出打印到 Symfony 2 中的浏览器控制台

php - 如果返回 0 行,则 MySQL 返回结果

php - 从单独下载的 JPEG 创建电影时帧速率太慢

php - 找不到 cakephp 数据库

php - Mongo groupby 在 Laravel raw 方法中没有使用不同的时间

php - while( var 行 = fn() );

python - 类型错误 : query() argument 1 must be string or read-only buffer, 不是元组

python - SQLAlchemy:相同的表但不同的数据库引擎

Laravel:无法安装哨兵

php - 在 Laravel homestead 中启用 MSSQL 支持的正确方法是什么?