Tag : WHERE Query


Laravel 5.3 - whereDate(), whereMonth(), whereDay() and whereYear() examples.

Laravel is a very popular PHP framework. Laravel 5.3 release few days ago and there are several new feature added by Laravel. Laravel 5.3 introduce several new where conditions like whereDate(), whereMonth() etc in Query Builder. Today, i am going to show you how to use it in your Laravel Application. I give you one example table and understand how works this four query builder functions one by one. So, first you can see bellow table with some records. <strong>products table</strong> <img src="/upload/product-table.png" style="width:100%;border:1px solid red"> <strong>whereDate()</strong> .....

By Hardik Savani | September 6, 2016 | | 2283 Viewer | Category : Laravel
READ MORE

How to get current month records in Laravel 5?

In this post, i give you example query of how to fetch current month records from table using Laravel query builder. We sometimes require to get records that created on current month. i.e if current month is august and we need display records of august month on out admin dashboard. In this example you can see how can get you current month records and i used whereRaw() of laravel query builder with MONTH() mysql that way we can get month and compare with current month. I have one created items table that structure as bellow you can see. <strong>items table</strong> <img src="/upload/laravel-.....

By Hardik Savani | August 7, 2016 | | 1083 Viewer | Category : Laravel
READ MORE

Laravel 5 - where condition with two columns example code

Laravel 5 introduce whereColumn() in Query Builder, that way we can compare two column like simple where condition. We sometimes require to check this type of condition. In this example code, i have simple "items" table and i want to get only created_at and updated_at column should equals. So you can also check bellow laravel eloquent as bellow: <strong>Example:</strong> <pre class="prettyprint lang-php"> $data = DB::table("items") ->whereColumn('created_at','updated_at') ->get(); print_r($data); </pre> <strong>Example 2:</strong> <pre class="prettyprint lang-php"> .....

By Hardik Savani | July 29, 2016 | | 884 Viewer | Category : Laravel
READ MORE

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 | | 802 Viewer | Category : Laravel
READ MORE

Laravel 5 - like query example using eloquent where clause.

Whenever you require to use select like query in your application then you can easily use. Laravel 5 provide query builder and mysql like condition is very simple to use. So let's see bellow example did convert bellow sql query. <strong>SQL Example:</strong> <pre> SELECT * FROM `users` WHERE `name` LIKE '%hdtopi%'; </pre> <strong>Laravel Query Example:</strong> <pre> $search = 'hdtopi'; $user = User::where('name','LIKE',"%{$search}%") ->get(); print_r($user); </pre>

By Hardik Savani | April 28, 2016 | | 2547 Viewer | Category : Laravel
READ MORE

    Multi select autocomplete jquery example with code

    Multi select autocomplete jquery example with code

    Open Post

    PHP - How to Convert file(image, audio, video) extension using CloudConvert API?

    PHP - How to Convert file(image, audio, video) extension using CloudConvert API?

    Open Post

    How to add charts in Laravel 5 using Highcharts ?

    How to add charts in Laravel 5 using Highcharts ?

    Open Post

    Laravel 5 Facebook authentication using Socialite Package

    Laravel 5 Facebook authentication using Socialite Package

    Open Post

    Laravel 5 - Image Upload and Resize Example using Intervention Image Package

    Laravel 5 - Image Upload and Resize Example using Intervention Image Package

    Open Post

    How to connect mysql database in node js with example?

    How to connect mysql database in node js with example?

    Open Post