Tag : orderBy


How to get last record from MySQL table in Codeigniter?

In this post we are going to learn how to get last single record from MySQl database table using Codeigniter database library. We sometime require to get only single row result in our Codeigniter application. In this post you can see how to get whole last record using Codeigniter db query. Few day ago i posted <a href="http://itsolutionstuff.com/post/how-to-get-last-inserted-id-in-codeigniterexample.html" target="_blank">"How to get last inserted id in Codeigniter?"</a>, in that post we can simply get last inserted id from Codeigniter db query. In this database query i used order_by(), limit.....

By Hardik Savani | March 9, 2017 | | 3258 Viewer | Category : MySql Codeigniter
READ MORE

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

    Laravel 5 create custom artisan command with example

    Laravel 5 create custom artisan command with example

    Open Post

    How to integrate stripe payment gateway in Laravel 5.4 Application ?

    How to integrate stripe payment gateway in Laravel 5.4 Application ?

    Open Post

    Codeigniter - Dynamic dependent dropdown using jquery ajax Example

    Codeigniter - Dynamic dependent dropdown using jquery ajax Example

    Open Post

    Bootstrap form validation example with demo using validator.js plugin

    Bootstrap form validation example with demo using validator.js plugin

    Open Post

    Bootstrap daterangepicker example code with demo using daterangepicker.js

    Bootstrap daterangepicker example code with demo using daterangepicker.js

    Open Post

    Laravel 5 - Paypal Payment Integration example using netshell/paypal package from scratch

    Laravel 5 - Paypal Payment Integration example using netshell/paypal package from scratch

    Open Post