@@ -12,7 +12,6 @@ Having been introduced to learning Laravel Framework; Over the past yr(s), Comin
1212was pretty tough. So i decided to create a much more easier way of communicating with Database, using native ` PHP PDO:: Driver ` .
1313
1414
15-
1615* [ Requirements] ( #requirements )
1716* [ Installation] ( #installation )
1817* [ Instantiate] ( #instantiate )
@@ -104,7 +103,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
104103** Step 1** — update your ` composer.json ` :
105104``` composer.json
106105"require" : {
107- "peterson/php-orm-database" : " ^3.1.4 "
106+ "peterson/php-orm-database" : " ^3.1.5 "
108107}
109108```
110109
@@ -183,8 +182,6 @@ $db->table('users')
183182</details >
184183
185184## More Database Connection Keys
186- <details ><summary >Read more...</summary >
187-
188185- All available connection keys
189186 - The DRIVER_NAME uses only ` mysql `
190187 - No other connection type is supported for now.
@@ -201,7 +198,6 @@ $db->table('users')
201198| DB_PORT | int | ` 3306 ` |
202199| DB_CHARSET | string | ` utf8mb4_unicode_ci ` |
203200| DB_COLLATION | string | ` utf8mb4 ` |
204- </details >
205201
206202## Usage
207203- All Methods of usage
@@ -279,7 +275,6 @@ $db->table('users')
279275```
280276
281277### Increment
282- <details ><summary >Read more...</summary >
283278
284279- Takes three parameter
285280 - Only the first param is required
@@ -301,25 +296,20 @@ $db->table('users')
301296$db->table('users')
302297 ->where('user_id', 10000001)
303298 ->increment('wallet_bal', 10);
304-
305- -- Query
306- UPDATE `users`
307- SET wallet_bal=wallet_bal+:10
308- WHERE user_id=:user_id
309299```
310300
311301- You can also pass in a second or third parameter to update additional columns
312302```
313303$db->table('users')
314304 ->where('user_id', 10000001)
315- ->increment('wallet_bal', 10 , [
305+ ->increment('wallet_bal', 100.23 , [
316306 'first_name' => 'F. Peterson',
317307 'status' => 1,
318308 ]);
319309
320310-- Query
321311UPDATE `users`
322- SET wallet_bal=wallet_bal+:10 , first_name=:first_name, status=:status
312+ SET wallet_bal=wallet_bal + :wallet_bal , first_name=:first_name, status=:status
323313 WHERE user_id=:user_id
324314```
325315
@@ -332,7 +322,6 @@ $db->table('users')
332322 'status' => 1,
333323 ]);
334324```
335- </details >
336325
337326### Decrement
338327- Same as Increment
@@ -368,26 +357,23 @@ SELECT count(*) FROM users WHERE status=:status
368357</details >
369358
370359### Remove Tags
371- <details ><summary >Read more...</summary >
372-
373- - Helps against ` XSS attacks `
374- - By default we remove-prevention of ` XSS attacks ` as this should already been handled by Forms Validation before sending into the Database
375- -> Applies to ` insert ` ` update ` ` increment ` ` decrement ` methods.
360+ - Takes one param as ` bool ` Default is ` false `
361+ - Helps against ` XSS attacks `
362+ - By default we did not handle ` XSS attacks ` . As we assume this should be done by ` Forms Validation ` before sending to Database
363+ -> Applies to ` insert ` ` update ` ` increment ` ` decrement ` methods.
376364
377365- 1 usage
378366```
379367$db->table('post')
380- ->removeTags()
368+ ->removeTags(true )
381369 ->insert([
382- 'description' => ' <script> alert(2); console.log('Blossom');</script>' ,
370+ 'description' => " <script> alert(2); console.log('Blossom');</script>" ,
383371 'user_id' =>
384372 ])
385373
386- -- Query
387- The value should be 'empty' if found as an attack
388- Now the method automatically apply strict method of cleaning each values
374+ - If param set to true, then this will allow all possible tags
375+ - If false, it will allow few supported HTML5 tags
389376```
390- </details >
391377
392378## Fetching Data
393379
@@ -454,8 +440,6 @@ SELECT * FROM `users`
454440```
455441
456442### Exists
457- <details ><summary >Read more...</summary >
458-
459443```
460444$db->table('users')
461445 ->where('email', '[email protected] ') @@ -465,7 +449,6 @@ $db->table('users')
465449-- Query
466450SELECT EXISTS(SELECT 1 FROM `users` WHERE email=:email OR name=:name) as `exists`
467451```
468- </details >
469452
470453### Table Exist
471454- Takes param as ` string ` ` $table_name `
@@ -476,11 +459,11 @@ $db->tableExist('users');
476459## Collections
477460- You can directly use ` methods ` of ` Collections Instance ` on any of the below
478461 - All the below ` methods ` are received by Collection ` class `
479- 1. get()
480- 2. first()
481- 3. firstOrFail()
482- 4. insert()
483- 5. insertOrIgnore()
462+ 1 . get()
463+ 2 . first()
464+ 3 . firstOrFail()
465+ 4 . insert()
466+ 5 . insertOrIgnore()
484467
485468
486469
@@ -660,7 +643,6 @@ $users->showing([
660643- Multiple clause
661644
662645### Raw
663- <details ><summary >Read more...</summary >
664646- Allows you to use direct raw ` SQL query syntax `
665647
666648```
@@ -670,7 +652,7 @@ $date = strtotime('next week');
670652$db->table("tb_wallet")
671653 ->raw("date >= $date")
672654 ->raw("NOW() > created_at")
673- ->raw("YEAR(created_at) = ' 2022' ")
655+ ->raw("YEAR(created_at) = 2022")
674656 ->where('email', '[email protected] ') 675657 ->limit(10)
676658 ->random()
@@ -681,12 +663,10 @@ $db->table("tb_wallet")
681663SELECT * FROM `tb_wallet`
682664 WHERE date >= 1681178855
683665 AND NOW() > created_at
684- AND YEAR(created_at) = ' 2022'
666+ AND YEAR(created_at) = 2022
685667 AND email=:email
686668 ORDER BY RAND() LIMIT 10
687669```
688- </details >
689-
690670
691671### Select
692672- Used to select needed columns from database
0 commit comments