|
57 | 57 | ``` |
58 | 58 | ### Where 3 |
59 | 59 | ```php |
60 | | -$select->whereBind(function($inst) { |
61 | | - $select->where("start_date", "2023-01-01", ">=") |
| 60 | +$select->whereBind(function($select) { |
| 61 | + $select |
| 62 | + ->where("start_date", "2023-01-01", ">=") |
62 | 63 | ->where("end_date", "2023-01-14", "<="); |
63 | 64 | })->or()->whereStatus(1); |
64 | 65 | // (start_date >= '2023-01-01' AND end_date <= '2023-01-14') OR (status = '1') |
@@ -97,8 +98,20 @@ $select->orderRaw("id ASC, parent DESC"); |
97 | 98 | // ORDER BY id ASC, parent DESC |
98 | 99 | ``` |
99 | 100 | ### Join |
| 101 | +**Note** that no value in the join is, by default, enclosed. This means it will not add quotes to strings. This means it will attempt to add a database column by default if it is a string, and will return an error if the string column does not exist. If you want to enclose the value with quotes, use Attributes (see the section below). |
100 | 102 | ```php |
101 | 103 | $select->join(["login", "aliasB"], ["aliasB.user_id" => "aliasA.id"]); // PROTECTED INPUT |
| 104 | + |
| 105 | +$select->join("login", ["user_id" => "id"]); |
| 106 | +// user_id = id AND org_id = oid |
| 107 | + |
| 108 | +// This will enclose and reset all protections |
| 109 | +$slug = DB::withAttr("my-slug-value"); |
| 110 | +$select->join("login", [ |
| 111 | + ["slug" => $slug], |
| 112 | + ["visible" => 1] |
| 113 | +]); |
| 114 | + |
102 | 115 | $select->join("tableName", "b.user_id = '%d'", [872], "LEFT"); // PROTECTED INPUT |
103 | 116 | $select->join("tableName", "b.user_id = a.id"); // "UNPROTECTED" INPUT |
104 | 117 |
|
@@ -191,5 +204,5 @@ public function jsonEncode(bool $jsonEncode): self; |
191 | 204 | - Input value: array("firstname" => "John", "lastname" => "Doe"); |
192 | 205 | - Output value: {"firstname":"John","lastname":"Doe"} |
193 | 206 |
|
194 | | -The default values vary based on whether it is a table column, a condition in a WHERE clause, or a value to be set. For instance, columns default to enclose set to false, whereas for WHERE or SET inputs, it defaults to true. Regardless, every value defaults to **prep**, **encode** and **jsonEncode** being set to **true**. |
| 207 | +The default values vary based on whether it is a table column, a condition in a WHERE clause, or a value to be set. For instance, if expecting a table columns, the default is not to enclose value with quotes, whereas for WHERE or SET inputs, it defaults is to enclose the values. Regardless, every value defaults to **prep**, **encode** and **jsonEncode** being set to **true**. |
195 | 208 |
|
0 commit comments