Friday 15 May 2015

mysql - How to run complex sql query in Laravel -



mysql - How to run complex sql query in Laravel -

i have complex sql consists of series of non-query statements, create utilize of temporary tables in mysql, , select statement @ end homecoming result.

e.g

drop table if exists temp_foo; create temporary table if not exists temp_foo ( select * foo ); select * temp_foo;

how can run in 1 db phone call laravel , results of lastly select statment?

i've tried doing in laravel, gives me mysql syntax error, unusual exact sql works ok when run straight in mysql.

db::select(" drop table if exists temp_foo; create temporary table if not exists temp_foo ( select * foo ); select * temp_foo; ");

any ideas on how can create work?

you need utilize db::raw() create query work, example:

db::select(db::raw(" drop table if exists temp_foo; create temporary table if not exists temp_foo ( select * foo ); select * temp_foo; "));

i think it's possible utilize selectraw() i'm not sure. also, can select rows temp_foo this:

db::table('temp_foo')->get();

mysql laravel laravel-4

No comments:

Post a Comment