jeudi 20 août 2015

laravel raw php query to order varhcar column as number

I am working with php Laravel Framework. So I have made a query to order a column called price which it's a varchar datatype in MySQL database asc.

$data =  Data::selectRaw('Dbname.tablename.*, Convert(price ,decimal )  as price  )->orderBy('price','asc')->where('service_id',$service_id) ->limit(100)->get(array('price' ));

The problem

If there value like 350,000 the output displayed in the page as just 350 or value like 5,000,000 it displayed as 5.

laravel php laravel 5 laravel 4 laravel with laravel tutorial

Aucun commentaire:

Enregistrer un commentaire