im trying to use mysql_num_rows in laravel but laravel says it not the same way like in 'raw php'
example:
$users = DB::table('users')
->where('username', '=', $username)
->where('password', '=', $password)
->get();
what i want to do:
$count = mysql_num_rows($users);
if($count > 0 ){
$user->login = $request->login;
$user->email = $request->email;
$user->password = $request->password;
Auth::login($user);
return redirect("/");
}else{
return "datos incorrectos";
}
what laravel says:
Call to undefined function App\Http\Controllers\Auth\mysql_num_rows()
PD: its not philosophy of code just make commets about that question, i dont want answers like "u gonna crypt that thing?", "why not use [insert my faborite ORM]" is just a simple question THANKS
Instead of using mysql_* functions, you should use count()
instead. It can be chained to Eloquent, query builder, or collections.
$users_count = DB::table('users')
->where('username', '=', $username)
->where('password', '=', $password)
->count();