vendredi 23 octobre 2015

Laravel 5.1 - Simple SQL Query gives errors

Trying to run a simple SQL query, but I keep getting the same error and I can't find a solution.

The Query

    $user_id = Auth::user()->id;
    $article_id = Request::input('articleId');
    $results = DB::select('select *
                          from favorites
                          where user_id = $user_id AND article_id = $article_id');

The variables $user_id and $article_id work, I tested that by echo'ing them.

The error I'm getting

SQLSTATE[42S22]: Column not found: 1054 Unknown column '$user_id' in 'where clause' (SQL: select * from favorites where user_id = $user_id AND article_id = $article_id)

my favorites table

1

How can I solve this issue? Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire