File tree Expand file tree Collapse file tree 2 files changed +6
-26
lines changed
Expand file tree Collapse file tree 2 files changed +6
-26
lines changed Original file line number Diff line number Diff line change 22
33namespace Furkifor \SqlDumper ;
44
5-
6- use Furkifor \SqlDumper \SqlQuery ;
7-
8-
95class SqlDumperClass
106{
117 public $ query ;
@@ -18,9 +14,8 @@ class SqlDumperClass
1814 public $ whereCount ;
1915 public $ with ;
2016
21- function __construct ($ table )
17+ public function __construct ($ table )
2218 {
23-
2419 $ this ->table = $ table ;
2520 $ this ->query = '' ;
2621 $ this ->select = '' ;
@@ -30,62 +25,50 @@ function __construct($table)
3025 $ this ->limit = '' ;
3126 $ this ->with = '' ;
3227 $ this ->whereCount = 0 ;
33-
3428 }
3529
36-
3730 public function select (string $ select = '* ' )
3831 {
3932 $ this ->select = "SELECT $ select FROM " ;
33+
4034 return $ this ;
4135 }
4236
43-
4437 public function orderBy ($ variable , $ type )
4538 {
4639 $ this ->orderBy .= " ORDER BY $ variable $ type " ;
40+
4741 return $ this ;
4842 }
4943
5044 public function where ($ where )
5145 {
52-
5346 if ($ this ->whereCount == 0 ) {
54-
5547 $ this ->where .= " WHERE $ where " ;
5648 $ this ->whereCount = 1 ;
57-
5849 } else {
59-
6050 $ this ->where .= " and $ where " ;
61-
6251 }
6352
6453 return $ this ;
6554 }
6655
6756 public function with ($ with , $ sql )
6857 {
69-
7058 $ this ->with .= preg_replace ('/this/i ' , $ this ->table , ' ' . $ with . ' JOIN ' . $ sql );
71- return $ this ;
7259
60+ return $ this ;
7361 }
7462
75-
7663 public function limit ($ count )
7764 {
7865 $ this ->limit .= " LIMIT $ count " ;
66+
7967 return $ this ;
8068 }
8169
8270 public function get ()
8371 {
8472 return print_r (@$ this ->select . @$ this ->table . @$ this ->with . @$ this ->where . @$ this ->orderBy . @$ this ->limit )[0 ];
85-
86-
8773 }
88-
89-
9074}
91-
Original file line number Diff line number Diff line change 22
33namespace Furkifor \SqlDumper \Tests ;
44
5- use PHPUnit \Framework \TestCase ;
6- use Furkifor \SqlDumper ;
7-
8- class ExampleTest
5+ class ExampleTest
96{
107 /** @test */
118 public function true_is_true ()
You can’t perform that action at this time.
0 commit comments