Skip to content

Commit 994b867

Browse files
author
Fredrick Peter
committed
push
1 parent a73c2d5 commit 994b867

File tree

2 files changed

+95
-7
lines changed

2 files changed

+95
-7
lines changed

README.md

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
104104
**Step 1** — update your `composer.json`:
105105
```composer.json
106106
"require": {
107-
"peterson/php-orm-database": "^2.2.9"
107+
"peterson/php-orm-database": "^1.0.5"
108108
}
109109
```
110110

@@ -527,6 +527,8 @@ if($users->isNotEmpty()){
527527

528528

529529
### Global Configuration
530+
<details><summary>Read more...</summary>
531+
530532
- 1 Setup global pagination on ENV autostart `most preferred` method
531533
```
532534
AutoloadEnv::configurePagination([
@@ -561,6 +563,7 @@ $db = new DB([
561563
'prev' => 'Prev Page',
562564
]);
563565
```
566+
</details>
564567

565568
### Pagination Query
566569
```
@@ -586,6 +589,8 @@ $users->links();
586589
```
587590

588591
### Pagination Links Config
592+
<details><summary>Read more...</summary>
593+
589594
- You can directly configure pagination links
590595
- Note: If `configurePagination()` `allow` is set to `true`
591596
- It'll override every other settings
@@ -597,6 +602,7 @@ $users->links([
597602
'next' => 'Next Page',
598603
])
599604
```
605+
</details>
600606

601607
### Pagination Showing
602608
```
@@ -609,6 +615,8 @@ $users->showing();
609615
```
610616

611617
### Pagination Showing Config
618+
<details><summary>Read more...</summary>
619+
612620
- You can configure showing text directly as well
613621
```
614622
$users->showing([
@@ -619,29 +627,42 @@ $users->showing([
619627
'span' => 'css-selector',
620628
])
621629
```
630+
</details>
622631

623632
## Clause
624633
- Multiple clause
625634

626-
<details><summary>[Raw](###Raw)</summary>
635+
### Raw
636+
<details><summary>Read more...</summary>
627637
- Allows you to use direct raw `SQL query syntax`
628638

629639
```
640+
$date = strtotime('next week');
641+
642+
630643
$db->table("tb_wallet")
631-
->where('email', '[email protected]')
632-
->raw("date >= 1681178855")
644+
->raw("date >= $date")
633645
->raw("NOW() > created_at")
634646
->raw("YEAR(created_at) = '2022'")
647+
->where('email', '[email protected]')
635648
->limit(10)
636649
->random()
637650
->get();
638651
639-
SELECT * FROM `tb_wallet` WHERE email=:email AND date >= 1681178855 AND NOW() > created_at AND YEAR(created_at) = '2022' ORDER BY RAND() LIMIT 10
652+
653+
-- Query
654+
SELECT * FROM `tb_wallet`
655+
WHERE date >= 1681178855
656+
AND NOW() > created_at
657+
AND YEAR(created_at) = '2022'
658+
AND email=:email
659+
ORDER BY RAND() LIMIT 10
640660
```
641661
</details>
642662

643663

644-
<details><summary>[Select](###Select)</summary>
664+
### Select
665+
<details><summary>Read more...</summary>
645666
- Used to select needed columns from database
646667

647668
```
@@ -660,8 +681,10 @@ SELECT first_name, email
660681

661682

662683
### orderBy
684+
<details><summary>Read more...</summary>
663685
- Takes two param `$column` and `$direction`
664686
- By default `$direction` param is set to `ASC`
687+
665688
```
666689
$db->table('wallet')
667690
->orderBy('date', 'DESC')
@@ -672,9 +695,13 @@ SELECT *
672695
FROM `wallet`
673696
ORDER By date DESC
674697
```
698+
</details>
699+
675700

676701
### orderByRaw
702+
<details><summary>Read more...</summary>
677703
- Takes one param `$query`
704+
678705
```
679706
$db->table('wallet')
680707
->orderByRaw('CAST(`amount` AS UNSIGNED) DESC')
@@ -685,8 +712,12 @@ SELECT *
685712
FROM `wallet`
686713
ORDER By CAST(`amount` AS UNSIGNED) DESC
687714
```
715+
</details>
716+
688717

689718
### Latest
719+
<details><summary>Read more...</summary>
720+
690721
- Takes one param `$column` by default the column used is `id`
691722
```
692723
$db->table('wallet')
@@ -698,8 +729,12 @@ SELECT *
698729
FROM `wallet`
699730
ORDER By date DESC
700731
```
732+
</details>
733+
701734

702735
### Oldest
736+
<details><summary>Read more...</summary>
737+
703738
- Takes one param `$column` by default the column used is `id`
704739
```
705740
$db->table('wallet')
@@ -711,8 +746,11 @@ SELECT *
711746
FROM `wallet`
712747
ORDER By id ASC
713748
```
749+
</details>
714750

715751
### inRandomOrder
752+
<details><summary>Read more...</summary>
753+
716754
```
717755
$db->table('wallet')
718756
->inRandomOrder()
@@ -723,16 +761,22 @@ SELECT *
723761
FROM `wallet`
724762
ORDER BY RAND()
725763
```
764+
</details>
726765

727766
### random
767+
<details><summary>Read more...</summary>
768+
728769
- Same as `inRandomOrder()`
729770
```
730771
$db->table('wallet')
731772
->random()
732773
->get();
733774
```
775+
</details>
734776

735777
### limit
778+
<details><summary>Read more...</summary>
779+
736780
- Takes one param `$limit` as int. By default value is `1`
737781
```
738782
$db->table('wallet')
@@ -744,8 +788,11 @@ SELECT *
744788
FROM `wallet`
745789
LIMIT 10
746790
```
791+
</details>
747792

748793
### offset
794+
<details><summary>Read more...</summary>
795+
749796
- Takes one param `$offset` as int. By default value is `0`
750797
```
751798
$db->table('wallet')
@@ -759,6 +806,7 @@ SELECT *
759806
LIMIT 2, 3
760807
```
761808

809+
762810
- Example 2 (Providing only offset will return as LIMIT without error)
763811
```
764812
$db->table('wallet')
@@ -770,8 +818,11 @@ SELECT *
770818
FROM `wallet`
771819
LIMIT 2
772820
```
821+
</details>
773822

774823
### join
824+
<details><summary>Read more...</summary>
825+
775826
| Params | Description |
776827
|---------------|-------------------|
777828
| table | table |
@@ -788,8 +839,11 @@ SELECT *
788839
FROM `wallet`
789840
INNER JOIN `users` ON users.user_id = wallet.user_id
790841
```
842+
</details>
791843

792844
### leftJoin
845+
<details><summary>Read more...</summary>
846+
793847
- Same as `join`
794848
```
795849
$db->table('wallet')
@@ -800,8 +854,11 @@ SELECT *
800854
FROM `wallet`
801855
LEFT JOIN `users` ON users.user_id = wallet.user_id
802856
```
857+
</details>
803858

804859
### where
860+
<details><summary>Read more...</summary>
861+
805862
- Takes three parameter
806863
- Only the first param is required
807864

@@ -822,8 +879,11 @@ SELECT *
822879
FROM `wallet`
823880
WHERE user_id=:user_id AND amount >: amount AND balance >= : balance
824881
```
882+
</details>
825883

826884
### orWhere
885+
<details><summary>Read more...</summary>
886+
827887
- Same as Where clause
828888
```
829889
$db->table('wallet')
@@ -839,8 +899,11 @@ SELECT *
839899
WHERE user_id=:user_id AND amount > :amount
840900
OR first_name like :first_name AND amount <= :amount
841901
```
902+
</details>
842903

843904
### whereColumn
905+
<details><summary>Read more...</summary>
906+
844907
- Takes three parameter `column` `operator` `column2`
845908
```
846909
$db->table('wallet')
@@ -855,8 +918,11 @@ SELECT *
855918
WHERE user_id=:user_id AND amount=tax
856919
AND amount <= balance
857920
```
921+
</details>
858922

859923
### whereNull
924+
<details><summary>Read more...</summary>
925+
860926
- Takes one parameter `column`
861927
```
862928
$db->table('wallet')
@@ -869,8 +935,11 @@ SELECT *
869935
FROM `wallet`
870936
WHERE user_id=:user_id AND email_status IS NULL
871937
```
938+
</details>
872939

873940
### whereNotNull
941+
<details><summary>Read more...</summary>
942+
874943
- Takes one parameter `column`
875944
```
876945
$db->table('wallet')
@@ -883,8 +952,11 @@ SELECT *
883952
FROM `wallet`
884953
WHERE user_id=:user_id AND email_status IS NOT NULL
885954
```
955+
</details>
886956

887957
### whereBetween
958+
<details><summary>Read more...</summary>
959+
888960
- Takes two parameter `column` as string `param` as array
889961
- Doesn't support float value
890962

@@ -904,8 +976,11 @@ SELECT *
904976
FROM `wallet`
905977
WHERE user_id=:user_id AND amount BETWEEN :0 AND :100
906978
```
979+
</details>
907980

908981
### whereNotBetween
982+
<details><summary>Read more...</summary>
983+
909984
- Same as `whereBetween()` method
910985

911986
```
@@ -919,8 +994,11 @@ SELECT *
919994
FROM `wallet`
920995
WHERE user_id=:user_id AND amount NOT BETWEEN :0 AND :100
921996
```
997+
</details>
922998

923999
### whereIn
1000+
<details><summary>Read more...</summary>
1001+
9241002
- Takes two parameter `column` as string `param` as array
9251003
- Doesn't support float value
9261004

@@ -940,8 +1018,11 @@ SELECT *
9401018
FROM `wallet`
9411019
WHERE user_id=:user_id AND amount IN (:10, :20, :40, :100)
9421020
```
1021+
</details>
9431022

9441023
### whereNotIn
1024+
<details><summary>Read more...</summary>
1025+
9451026
Same as `whereIn()` method
9461027
```
9471028
$db->table('wallet')
@@ -954,8 +1035,11 @@ SELECT *
9541035
FROM `wallet`
9551036
WHERE user_id=:user_id AND amount NOT IN (:10, :20, :40, :100)
9561037
```
1038+
</details>
9571039

9581040
### groupBy
1041+
<details><summary>Read more...</summary>
1042+
9591043
- Takes one param `$column`
9601044
```
9611045
$db->table('wallet')
@@ -968,6 +1052,7 @@ SELECT *
9681052
FROM `wallet`
9691053
WHERE user_id=:user_id GROUP BY amount
9701054
```
1055+
</details>
9711056

9721057
## Database Migration
9731058
- Similar to Laravel DB Migration `Just to make database table creation more easier`
@@ -982,6 +1067,8 @@ use builder\Database\Migrations\Migration;
9821067
```
9831068

9841069
### Create Table Schema
1070+
<details><summary>Read more...</summary>
1071+
9851072
- Takes param as `table name`
9861073
- Second parameter `string` `jobs|sessions` (optional) -If passed will create a dummy `jobs|sessions` table schema
9871074

@@ -998,6 +1085,7 @@ Table `2023_04_19_1681860618_tb_jobs` has been created successfully
9981085
Table `2023_04_19_1681860618_tb_sessions` has been created successfully
9991086
```
10001087
![Sample Session Schema](https://raw.githubusercontent.com/tamedevelopers/UltimateOrmDatabase/main/sessions.png)
1088+
</details>
10011089

10021090
### Run Migration
10031091

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"extra": {
3939
"branch-alias": {
40-
"dev-main": "2.2.9-dev"
40+
"dev-main": "1.0.5-dev"
4141
}
4242
},
4343
"minimum-stability": "stable",

0 commit comments

Comments
 (0)