Skip to content

Commit c8ab142

Browse files
update
1 parent ebdf3c0 commit c8ab142

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ was pretty tough. So i decided to create a much more easier way of communicating
5555
* [Pagination Foreach Numbers](#pagination-foreach-numbers)
5656
* [Get Pagination](#get-pagination)
5757
* [Clause](#clause)
58-
* [Raw](#raw)
5958
* [Query](#query)
6059
* [select](#select)
6160
* [selectRaw](#selectRaw)
@@ -70,8 +69,8 @@ was pretty tough. So i decided to create a much more easier way of communicating
7069
* [join](#join)
7170
* [leftJoin](#leftJoin)
7271
* [where](#where)
73-
* [where](#where)
7472
* [orWhere](#orwhere)
73+
* [whereRaw](#whereRaw)
7574
* [whereColumn](#wherecolumn)
7675
* [whereNull](#wherenull)
7776
* [orWhereNull](#orWhereNull)
@@ -633,29 +632,18 @@ $users->getPagination();
633632
## Clause
634633
- Multiple clause
635634

636-
### Raw
637-
- Allows you to use direct raw `SQL query syntax`
638-
639-
```
640-
$date = strtotime('next week');
641-
642-
$db->table("tb_wallet")
643-
->whereRaw("NOW() > created_at")
644-
->whereRaw("date >= ?", [$date])
645-
->where(DB::raw("YEAR(created_at) = 2022"))
646-
->where('email', '[email protected]')
647-
->limit(10)
648-
->random()
649-
->get();
650-
```
651-
652635
### Query
653636
- Allows the use direct sql query `SQL query syntax`
637+
- Or direct query exec()
654638

655639
```
656640
$db->query("SHOW COLUMNS FROM users")
657641
->limit(10)
658642
->get();
643+
644+
645+
$db->query("ALTER TABLE `langs` ADD COLUMN es TEXT; UPDATE `langs` SET es = en;")
646+
->exec();
659647
```
660648

661649
### Select
@@ -816,6 +804,22 @@ $db->table('wallet')
816804
```
817805
</details>
818806

807+
### whereRaw
808+
- Allows you to use direct raw `SQL query syntax`
809+
810+
```
811+
$date = strtotime('next week');
812+
813+
$db->table("tb_wallet")
814+
->whereRaw("NOW() > created_at")
815+
->whereRaw("date >= ?", [$date])
816+
->where(DB::raw("YEAR(created_at) = 2022"))
817+
->where('email', '[email protected]')
818+
->limit(10)
819+
->random()
820+
->get();
821+
```
822+
819823
### whereColumn
820824
- Takes three parameter `column` `operator` `column2`
821825
```

src/DBImport.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function import($path_to_sql)
8282
} else{
8383

8484
// check if connection test is okay
85-
if($this->DBConnect()){
85+
if($this->dbConnect()){
8686
try{
8787
// connection driver
8888
$pdo = $this->db['pdo'];
@@ -152,16 +152,11 @@ public function import($path_to_sql)
152152
/**
153153
* Check Database connection
154154
*
155-
* @return boolean
155+
* @return bool
156156
*/
157-
private function DBConnect()
157+
private function dbConnect()
158158
{
159-
// status
160-
if($this->db['status'] != Constant::STATUS_200){
161-
return false;
162-
}
163-
164-
return true;
159+
return $this->db['status'] == Constant::STATUS_200;
165160
}
166161

167162
}

src/Schema/Builder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ public function query(string $query)
5858

5959
return $this;
6060
}
61+
62+
/**
63+
* Execute the query strings
64+
*
65+
* @return int
66+
*/
67+
public function exec()
68+
{
69+
if (empty($this->query)) {
70+
throw new Exception("Query must be passed and not empty.");
71+
}
72+
73+
return $this->connection->pdo->exec($this->query);
74+
}
6175

6276
/**
6377
* Columns to be selected.

src/Traits/DBImportTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait DBImportTrait{
1111
* Check if data is Readable
1212
*
1313
* @param array|null $readFile
14-
* @return boolean
14+
* @return bool
1515
*/
1616
protected function isReadable(?array $readFile = null)
1717
{
@@ -25,7 +25,7 @@ protected function isReadable(?array $readFile = null)
2525
* Check if sql string is a comment
2626
*
2727
* @param string|null $string
28-
* @return boolean
28+
* @return bool
2929
*/
3030
protected function isComment($string = null)
3131
{
@@ -41,7 +41,7 @@ protected function isComment($string = null)
4141
* Check if sql string is a Query
4242
*
4343
* @param string|null $string
44-
* @return boolean
44+
* @return bool
4545
*/
4646
protected function isQuery($string = null)
4747
{

0 commit comments

Comments
 (0)