laravel - How make multiple subqueries with Eloquent? -


a have code:

    db::select('         select sum(count) count           (             select count(*) count ad_banners             union             select count(*) count ad_context             union             select count(*) count ad_content             union             select count(*) count ad_decoration             union             select count(*) count ad_front             union             select count(*) count ad_universal           ) ad'     ); 

how make query using eloquent orm methods , make sense? in advance!

edit:

i wrote code, attempts use eloquent ended fail. don't understand how make sub queries union , count. didn't wont write code me, enough small example. , sorry bad english.

have tried using db::raw() method? sometimes, if know sql want use don't know how use eloquent accomplish it, may use db::raw() results need. here's example, can tailor needs:

$query = db::connection('connection_name')->select(db::raw("select * table ...")); 

also, connection_name can found defined in app/config/database.php in connections array.

hope provides insight. without idea of models , relationships , you're trying accomplish, hard advise on eloquent solution issue.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -