mardi 10 avril 2018

Can i run query right after "php artisan serve"

Hello i am beginner at framework laravel, but for my school project i have to connect my application to postgresql database, that i have done and i already displayed everything what i needed but i have about 20 milion rows in my database and doing just simple query which will display 25rows approx. like this
AUDI | 876 984 FIAT | 756 867 SEAT | 678 985 FORD | 586 098 ...............

How can i store output of that query in some variable and then use it later for some calculations or reversing order and so on (it would be awesome if you could provide some sample code for it too...i myself put it all in controller in one method and when button is pressed the controller returns view with output of query and then in one file it is printed with for loop)

This is example of my diagram

ProductControler extends Controller {

        public function index(){
                $things = DB::table('table')
                                        ->select(array(as something1,as something2))
                                        ->join some stuff
                                        ->groupby some stuff
                                        ->orderby  some stuff
                                        ->get some stuff
                return view('layout.overview',compact('things'));
        }
}
-----------------------------------------------
in overview.blade.php is something like this
------------------------------------------------
@foreach($things as $thing)
        
        
@endforeach
-------------------------------------------------
and in routes something like this
------------------------------------------------
Route::get('products/', 'ProductControler@index');

dont click on run sorry i didnt know how to normally put my code in here..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire