phoenixg
6 months ago

How do I rewrite such sql into Eloquent style?

Posted 6 months ago by phoenixg
$sql = "(
                select ch_id from Charge 
                    where ch_order_no = :id and ch_app_id = 'app_id'
                union all
                select ch_id from Charge
                    where ch_id = :id and ch_app_id = 'app_id'
            ) as " . Charge::db()->getTablePrefix() . "t";
$queryCount = Charge::db()->table(Charge::db()->raw(str_replace('\n', ' ', $sql)));
var_dump($queryCount->count());

Please sign in or create an account to participate in this conversation.