Support the ongoing development of Laravel.io →
Database Eloquent

This code returns true when run and I don't get it. What am I doing wrong. Thanks guys!

profile = DB::table('profiles')->where('uid', $uid)->first();
        echo is_null($profile);

This code returns nothing ie. 0 or false but that shouldn't be the case as the database has a row with that uid.

Last updated 2 years ago.
0

I'd guess it's the where() clause. The second parameter is actually the comparison operator, not the value to compare against.

Try this:

$profile = DB::table('profiles')->where('uid', '=', $uid)->first();

echo is_null($profile);
Last updated 2 years ago.
0
$query = DB::getQueryLog();
                return Response::json(array(
                        'error' => true,
                        'message' => $e->getMessage(),
                        'trace' => $e->getTrace(),
                        'sql' => $query
                    ),
                    200
                );
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bonty233 bonty233 Joined 16 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.