Skip to content

Instantly share code, notes, and snippets.

@Carmageddon
Last active August 29, 2015 14:17
Show Gist options
  • Save Carmageddon/e108253f3878f153baa1 to your computer and use it in GitHub Desktop.
Save Carmageddon/e108253f3878f153baa1 to your computer and use it in GitHub Desktop.
Sample query for Eloquent
SELECT "Subscription".*
FROM "Subscription"
JOIN "Account" ON "Subscription"."AccountID" = "Account"."AccountID"
JOIN "PayTool" ON "Subscription"."AccountID" = "PayTool"."OwnerAccountID"
WHERE
(
(
("AdminPhNumber" = '4578568' AND "AdminPhAreaCode" = '54') OR ("BillPhNumber" = '4578568' AND "BillPhAreaCode" = '54') or ("TechPhNumber" = '4578568' AND "TechPhAreaCode" = '54') OR ("PersPhNumber" = '4578568' AND "PersPhAreaCode" = '54')
OR
("AdminFaxNumber" = '4578568' AND "AdminFaxAreaCode" = '54') OR ("BillFaxNumber" = '4578568' AND "BillFaxAreaCode" = '54') or ("TechFaxNumber" = '4578568' AND "TechFaxAreaCode" = '54') OR ("PersFaxNumber" = '4578568' AND "PersFaxAreaCode" = '54')
)
OR ("PayTool"."CutNumber" LIKE '%1234' AND "Account"."TaxRegID" = '123456789')
)
AND "Subscription"."Status" = 30
@janhartigan
Copy link

DB::table('Subscriptions as s')
    ->join('Account as a', 's.AccountID', '=', 'a.AccountID')
    ->join('PayTool as pt', 's.AccountID', '=', 'pt.OwnerAccountID')
    ->where('s.status', 30)
    ->where(function($query)
    {
        //see here: http://laravel.com/docs/5.0/queries#advanced-wheres
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment