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
Having command works the same as where command above with exception that you rename "where" in method to "having" and @havingBind do not exist.
73
+
Having command works the same as where command above with exception that you rename "where" method to "having" and that the method "havingBind" do not exist.
Each value is automatically escaped by default in the most effective manner to ensure consequential and secure data storage, guarding against SQL injection vulnerabilities. While it's possible to exert complete control over SQL input using various **Raw** methods, such an approach is not advisable due to the potential for mistakes that could introduce vulnerabilities. A safer alternative is to leverage the **Attr** class. The **Attr** class offers comprehensive configuration capabilities for nearly every value in the DB library, as illustrated below:
147
+
```php
148
+
$idValue = DB::withAttr("1")
149
+
->prep(true)
150
+
->enclose(true)
151
+
->encode(true)
152
+
->jsonEncode(true);
153
+
154
+
$select->where("id", $idValue);
155
+
```
156
+
#### Escape values and protect against SQL injections
157
+
```php
158
+
public function prep(bool $prep): self;
159
+
```
160
+
**Example:**
161
+
- Input value: Lorem "ipsum" dolor
162
+
- Output value: Lorem \\"ipsum\\" dolor
163
+
164
+
#### Enable/disable string enclose
165
+
```php
166
+
public function enclose(bool $enclose): self;
167
+
```
168
+
**Example:**
169
+
- Input value: 1186
170
+
- Output value: '1186'
171
+
*E.g. will add or remove quotes to values*
172
+
173
+
#### Enable/disable XSS protection
174
+
Some like to have the all the database data already HTML special character escaped.
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**.
0 commit comments