Laravel 5: How to run a RAW MySQL statement?
<p>So I have been moving from framework to framework and one feature that I liked about CodeIgniter over Laravel was that it supplys Raw statements.</p>

<p>I did some research on Laravel and the statements that they can supply and I found the DB::raw($sql) statement.</p>

<p>I tried initially to do the statement like so:</p>

<pre><code>$query = DB::raw("SELECT * FROM users WHERE username = 'admin');
foreach ($query as $q) {
  $id = $q['id'];
}
</code></pre>

<p>but that didnt manage to work, so I did some more research looking at stack overflow questions and I managed to find the structure was a bit different, so I tried:</p>

<pre><code>$query = DB::select(DB::raw("SELECT * FROM users WHERE username = 'admin');
</code></pre>

<p>then used the same foreach loop as I did in the first part to try to loop the data.</p>

<p>If this is the wrong way of using this method please let me know, also, I'm not planning on keeping this method for using raw statements and getting user data, I just am trying to know that is it able to be used.</p>