Tag : DB::raw()

ItSolutionStuff.com have tutorials for DB::raw() tag, here you can study articles of DB::raw() tag, DB::raw() tag posts collection, most popular and useful tutorials of DB::raw() tag, here you can find list of all relevant posts and example about DB::raw() tag, we have lists of tutorials and examples about DB::raw() tag. very simple and quick example collection of Latest DB::raw() tag.

Laravel where clause with date_format() example

In this post, i share with you that how to use date_format() with where condition of Laravel query builder. When i was working on my project, i require to search with get only selected month and year records from created_at(timestamp) column. I was thinking how can i but i know date_format() of mysql. but don't know how to use in laravel where clause. At last i use DB::raw() of Laravel and it's work. If you have also need to search this way then you can do it this way: <strong>Example:</strong> <pre class="prettyprint lang-php"> $data = DB::table("items") ->select("id","title","creat.....

By Hardik Savani | June 22, 2016 | | 27566 Viewer | Category : Laravel

Laravel 5 select with count query with group by example

We always required to get count of number of records or number of inserted record of current month etc in laravel. We can use mysql count function in laravel eloquent. We have two way to get count of column value. first we can use laravel count() of query builder and another one we can use with directly with select statement using DB::raw(). I give you both example you can see and use any one as perfect for you. <strong>Example 1:</strong> <pre class="prettyprint lang-php"> $data = DB::table("click")->count(); print_r($data); </pre> <strong>Example 2:</strong> <pre class="prettyprint lang-php.....

By Hardik Savani | June 9, 2016 | | 79216 Viewer | Category : Laravel

Laravel 5 - Orderby random using rand() and DB::raw() example

Sometimes, we require to get randomly data using laravel query builder. you can use mysql rand() with order by. If you want to get random data using laravel eloquent then we need to use DB::raw(). In bellow example you can i use DB::raw(). In this example i use DB::raw('RAND()') inside orderBy() and also add limit of 8 number of record, so you can easily implement in your laravel project. so let's try... <pre class="prettyprint lang-php"> return DB::table("posts") ->select("posts.*") ->orderBy(DB::raw('RAND()')) ->take(8) ->get(); </pre>

By Hardik Savani | May 4, 2016 | | 36656 Viewer | Category : Laravel