Devil System Devil System - 1 year ago 295
SQL Question

mysql_num_rows in laravel?

im trying to use mysql_num_rows in laravel but laravel says it not the same way like in 'raw php'


$users = DB::table('users')
->where('username', '=', $username)
->where('password', '=', $password)

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;

return redirect("/");
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

Answer Source

Don't use mysql_ functions.. you need ->count();

See Retrieving Aggregates here:

$users = DB::table('users')
     ->where('username', '=', $username)
     ->where('password', '=', $password)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download