You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can easily create unions by calling the `union` method on the `QueryBuilderHandler`.
577
+
578
+
Example:
579
+
580
+
```php
581
+
$firstQuery =
582
+
$queryBuilder
583
+
->table('people')
584
+
->whereNull('email');
585
+
586
+
$secondQuery =
587
+
$queryBuilder
588
+
->table('people')
589
+
->where('hair_color', '=', 'green')
590
+
->union($firstQuery);
591
+
592
+
$thirdQuery =
593
+
$queryBuilder
594
+
->table('people')
595
+
->where('gender', '=', 'male')
596
+
->union($secondQuery);
597
+
598
+
$items = $thirdQuery->get();
599
+
```
600
+
601
+
The example above will create a sql-statement similar to this:
602
+
603
+
```sql
604
+
(
605
+
SELECT*
606
+
FROM
607
+
`cb_people`
608
+
WHERE
609
+
`gender`='male'
610
+
)
611
+
UNION
612
+
(
613
+
SELECT*
614
+
FROM
615
+
`cb_people`
616
+
WHERE
617
+
`email`
618
+
IS NULL
619
+
)
620
+
UNION
621
+
(
622
+
SELECT*
623
+
FROM
624
+
`cb_people`
625
+
WHERE
626
+
`hair_color`='green'
627
+
)
628
+
```
629
+
571
630
#### Multiple Join Criteria
572
631
573
632
If you need more than one criterion to join a table then pass a closure as second parameter.
@@ -935,10 +994,18 @@ Pixie comes with powerful query events to supercharge your application. These ev
935
994
936
995
#### Registering Events
937
996
997
+
You can easily register a new event either by using the `registerEvent` method on either the `QueryBuilderHandler`, `Connection` or `EventHandler` class.
998
+
999
+
The event needs a custom callback function with a `EventArguments` object as parameters.
0 commit comments