Monday, February 27, 2017

[SOLVED]Query retrieve bad record

somthing wrong, when I run a query to retrieve a record in my database with a wrong ID I receive the result of another recording! Example :
The ID entered is =91TDFS78.
The result retrieve is of ID = 91.
in below query:
$idusers = \DB::table('users')
            ->select('users.*')
            ->where('id','=', $id)
            ->get();



from Latest question asked on Laravel tag.

via nabil UPDATE: Thank you for all, I have to do the test before running the query :
$isdigit = ctype_digit((string)$id);
if($isdigit){
$idusers = \DB::table('users')
            ->select('users.*')
            ->where('id','=', $id)
            ->get();
}

Advertisement