@@ -13,9 +13,9 @@ |
||
13 | 13 | trait Objects |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var QueryStructure |
|
18 | - */ |
|
19 | - protected $queryStructure; |
|
16 | + /** |
|
17 | + * @var QueryStructure |
|
18 | + */ |
|
19 | + protected $queryStructure; |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -13,56 +13,56 @@ |
||
13 | 13 | trait SetFields |
14 | 14 | { |
15 | 15 | |
16 | - use Objects; |
|
16 | + use Objects; |
|
17 | 17 | |
18 | - private $setValues; |
|
18 | + private $setValues; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param $fieldName |
|
22 | - * @param $fieldValue |
|
23 | - * @return $this |
|
24 | - */ |
|
25 | - public function setField($fieldName, $fieldValue) |
|
26 | - { |
|
27 | - $valuePdoString = $this->queryStructure->bindParam($fieldName, $fieldValue); |
|
28 | - $this->queryStructure->setElement(QueryStructure::SET_FIELDS, "$fieldName = $valuePdoString"); |
|
20 | + /** |
|
21 | + * @param $fieldName |
|
22 | + * @param $fieldValue |
|
23 | + * @return $this |
|
24 | + */ |
|
25 | + public function setField($fieldName, $fieldValue) |
|
26 | + { |
|
27 | + $valuePdoString = $this->queryStructure->bindParam($fieldName, $fieldValue); |
|
28 | + $this->queryStructure->setElement(QueryStructure::SET_FIELDS, "$fieldName = $valuePdoString"); |
|
29 | 29 | |
30 | - return $this; |
|
31 | - } |
|
30 | + return $this; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param string $expression |
|
35 | - * @return $this |
|
36 | - */ |
|
37 | - public function setFieldByExpression($expression) |
|
38 | - { |
|
39 | - $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $expression); |
|
33 | + /** |
|
34 | + * @param string $expression |
|
35 | + * @return $this |
|
36 | + */ |
|
37 | + public function setFieldByExpression($expression) |
|
38 | + { |
|
39 | + $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $expression); |
|
40 | 40 | |
41 | - return $this; |
|
42 | - } |
|
41 | + return $this; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Set fields by associative array ( fieldName => fieldValue ) |
|
46 | - * @param array $updateFieldsArray |
|
47 | - * @return $this |
|
48 | - */ |
|
49 | - public function setFieldsByArray(array $updateFieldsArray) |
|
50 | - { |
|
51 | - foreach ($updateFieldsArray as $fieldName => $fieldValue) |
|
52 | - $this->setField($fieldName, $fieldValue); |
|
44 | + /** |
|
45 | + * Set fields by associative array ( fieldName => fieldValue ) |
|
46 | + * @param array $updateFieldsArray |
|
47 | + * @return $this |
|
48 | + */ |
|
49 | + public function setFieldsByArray(array $updateFieldsArray) |
|
50 | + { |
|
51 | + foreach ($updateFieldsArray as $fieldName => $fieldValue) |
|
52 | + $this->setField($fieldName, $fieldValue); |
|
53 | 53 | |
54 | - return $this; |
|
55 | - } |
|
54 | + return $this; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - private function getSettingFieldsSyntax() |
|
61 | - { |
|
62 | - if (!count($this->queryStructure->getElement(QueryStructure::SET_FIELDS))) |
|
63 | - return ''; |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + private function getSettingFieldsSyntax() |
|
61 | + { |
|
62 | + if (!count($this->queryStructure->getElement(QueryStructure::SET_FIELDS))) |
|
63 | + return ''; |
|
64 | 64 | |
65 | - return 'SET ' . implode(', ', $this->queryStructure->getElement(QueryStructure::SET_FIELDS)); |
|
66 | - } |
|
65 | + return 'SET ' . implode(', ', $this->queryStructure->getElement(QueryStructure::SET_FIELDS)); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @param $fieldValue |
23 | 23 | * @return $this |
24 | 24 | */ |
25 | - public function setField($fieldName, $fieldValue) |
|
25 | + public function setField( $fieldName, $fieldValue ) |
|
26 | 26 | { |
27 | - $valuePdoString = $this->queryStructure->bindParam($fieldName, $fieldValue); |
|
28 | - $this->queryStructure->setElement(QueryStructure::SET_FIELDS, "$fieldName = $valuePdoString"); |
|
27 | + $valuePdoString = $this->queryStructure->bindParam( $fieldName, $fieldValue ); |
|
28 | + $this->queryStructure->setElement( QueryStructure::SET_FIELDS, "$fieldName = $valuePdoString" ); |
|
29 | 29 | |
30 | 30 | return $this; |
31 | 31 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * @param string $expression |
35 | 35 | * @return $this |
36 | 36 | */ |
37 | - public function setFieldByExpression($expression) |
|
37 | + public function setFieldByExpression( $expression ) |
|
38 | 38 | { |
39 | - $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $expression); |
|
39 | + $this->queryStructure->setElement( QueryStructure::SET_FIELDS, $expression ); |
|
40 | 40 | |
41 | 41 | return $this; |
42 | 42 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | * @param array $updateFieldsArray |
47 | 47 | * @return $this |
48 | 48 | */ |
49 | - public function setFieldsByArray(array $updateFieldsArray) |
|
49 | + public function setFieldsByArray( array $updateFieldsArray ) |
|
50 | 50 | { |
51 | - foreach ($updateFieldsArray as $fieldName => $fieldValue) |
|
52 | - $this->setField($fieldName, $fieldValue); |
|
51 | + foreach ( $updateFieldsArray as $fieldName => $fieldValue ) |
|
52 | + $this->setField( $fieldName, $fieldValue ); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private function getSettingFieldsSyntax() |
61 | 61 | { |
62 | - if (!count($this->queryStructure->getElement(QueryStructure::SET_FIELDS))) |
|
62 | + if ( !count( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ) ) |
|
63 | 63 | return ''; |
64 | 64 | |
65 | - return 'SET ' . implode(', ', $this->queryStructure->getElement(QueryStructure::SET_FIELDS)); |
|
65 | + return 'SET ' . implode( ', ', $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setFieldsByArray(array $updateFieldsArray) |
50 | 50 | { |
51 | - foreach ($updateFieldsArray as $fieldName => $fieldValue) |
|
52 | - $this->setField($fieldName, $fieldValue); |
|
51 | + foreach ($updateFieldsArray as $fieldName => $fieldValue) { |
|
52 | + $this->setField($fieldName, $fieldValue); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | return $this; |
55 | 56 | } |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | */ |
60 | 61 | private function getSettingFieldsSyntax() |
61 | 62 | { |
62 | - if (!count($this->queryStructure->getElement(QueryStructure::SET_FIELDS))) |
|
63 | - return ''; |
|
63 | + if (!count($this->queryStructure->getElement(QueryStructure::SET_FIELDS))) { |
|
64 | + return ''; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | return 'SET ' . implode(', ', $this->queryStructure->getElement(QueryStructure::SET_FIELDS)); |
66 | 68 | } |
@@ -15,68 +15,68 @@ |
||
15 | 15 | trait OrderBy |
16 | 16 | { |
17 | 17 | |
18 | - use Objects; |
|
18 | + use Objects; |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param $column |
|
23 | - * @param array $allowedColumns |
|
24 | - * @return $this |
|
25 | - * @throws QueryException |
|
26 | - */ |
|
27 | - public function orderBy($column, array $allowedColumns = []) |
|
28 | - { |
|
29 | - $column = trim($column); |
|
21 | + /** |
|
22 | + * @param $column |
|
23 | + * @param array $allowedColumns |
|
24 | + * @return $this |
|
25 | + * @throws QueryException |
|
26 | + */ |
|
27 | + public function orderBy($column, array $allowedColumns = []) |
|
28 | + { |
|
29 | + $column = trim($column); |
|
30 | 30 | |
31 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
32 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
31 | + if (!$this->validateColumn($column, $allowedColumns)) |
|
32 | + throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
33 | 33 | |
34 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column); |
|
34 | + $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column); |
|
35 | 35 | |
36 | - return $this; |
|
37 | - } |
|
36 | + return $this; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param $column |
|
42 | - * @param array $allowedColumns |
|
43 | - * @return $this |
|
44 | - * @throws QueryException |
|
45 | - */ |
|
46 | - public function orderByDesc($column, array $allowedColumns = []) |
|
47 | - { |
|
48 | - $column = trim($column); |
|
40 | + /** |
|
41 | + * @param $column |
|
42 | + * @param array $allowedColumns |
|
43 | + * @return $this |
|
44 | + * @throws QueryException |
|
45 | + */ |
|
46 | + public function orderByDesc($column, array $allowedColumns = []) |
|
47 | + { |
|
48 | + $column = trim($column); |
|
49 | 49 | |
50 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
51 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
50 | + if (!$this->validateColumn($column, $allowedColumns)) |
|
51 | + throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
52 | 52 | |
53 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column . ' DESC'); |
|
53 | + $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column . ' DESC'); |
|
54 | 54 | |
55 | - return $this; |
|
56 | - } |
|
55 | + return $this; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @param $expression |
|
61 | - * @return $this |
|
62 | - */ |
|
63 | - public function orderByExpression($expression) |
|
64 | - { |
|
65 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $expression); |
|
59 | + /** |
|
60 | + * @param $expression |
|
61 | + * @return $this |
|
62 | + */ |
|
63 | + public function orderByExpression($expression) |
|
64 | + { |
|
65 | + $this->queryStructure->setElement(QueryStructure::ORDER_BY, $expression); |
|
66 | 66 | |
67 | - return $this; |
|
68 | - } |
|
67 | + return $this; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function getOrderBySyntax() |
|
75 | - { |
|
76 | - if (count($this->queryStructure->getElement(QueryStructure::ORDER_BY))) |
|
77 | - return 'ORDER BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::ORDER_BY), ', '); |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function getOrderBySyntax() |
|
75 | + { |
|
76 | + if (count($this->queryStructure->getElement(QueryStructure::ORDER_BY))) |
|
77 | + return 'ORDER BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::ORDER_BY), ', '); |
|
78 | 78 | |
79 | - return ''; |
|
80 | - } |
|
79 | + return ''; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * @return $this |
25 | 25 | * @throws QueryException |
26 | 26 | */ |
27 | - public function orderBy($column, array $allowedColumns = []) |
|
27 | + public function orderBy( $column, array $allowedColumns = [ ] ) |
|
28 | 28 | { |
29 | - $column = trim($column); |
|
29 | + $column = trim( $column ); |
|
30 | 30 | |
31 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
32 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
31 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) |
|
32 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
33 | 33 | |
34 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column); |
|
34 | + $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
|
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @return $this |
44 | 44 | * @throws QueryException |
45 | 45 | */ |
46 | - public function orderByDesc($column, array $allowedColumns = []) |
|
46 | + public function orderByDesc( $column, array $allowedColumns = [ ] ) |
|
47 | 47 | { |
48 | - $column = trim($column); |
|
48 | + $column = trim( $column ); |
|
49 | 49 | |
50 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
51 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
50 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) |
|
51 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
52 | 52 | |
53 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column . ' DESC'); |
|
53 | + $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' ); |
|
54 | 54 | |
55 | 55 | return $this; |
56 | 56 | } |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @param $expression |
61 | 61 | * @return $this |
62 | 62 | */ |
63 | - public function orderByExpression($expression) |
|
63 | + public function orderByExpression( $expression ) |
|
64 | 64 | { |
65 | - $this->queryStructure->setElement(QueryStructure::ORDER_BY, $expression); |
|
65 | + $this->queryStructure->setElement( QueryStructure::ORDER_BY, $expression ); |
|
66 | 66 | |
67 | 67 | return $this; |
68 | 68 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function getOrderBySyntax() |
75 | 75 | { |
76 | - if (count($this->queryStructure->getElement(QueryStructure::ORDER_BY))) |
|
77 | - return 'ORDER BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::ORDER_BY), ', '); |
|
76 | + if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) ) |
|
77 | + return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' ); |
|
78 | 78 | |
79 | 79 | return ''; |
80 | 80 | } |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | { |
29 | 29 | $column = trim($column); |
30 | 30 | |
31 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
32 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
31 | + if (!$this->validateColumn($column, $allowedColumns)) { |
|
32 | + throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
33 | + } |
|
33 | 34 | |
34 | 35 | $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column); |
35 | 36 | |
@@ -47,8 +48,9 @@ discard block |
||
47 | 48 | { |
48 | 49 | $column = trim($column); |
49 | 50 | |
50 | - if (!$this->validateColumn($column, $allowedColumns)) |
|
51 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
51 | + if (!$this->validateColumn($column, $allowedColumns)) { |
|
52 | + throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | $this->queryStructure->setElement(QueryStructure::ORDER_BY, $column . ' DESC'); |
54 | 56 | |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | */ |
74 | 76 | private function getOrderBySyntax() |
75 | 77 | { |
76 | - if (count($this->queryStructure->getElement(QueryStructure::ORDER_BY))) |
|
77 | - return 'ORDER BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::ORDER_BY), ', '); |
|
78 | + if (count($this->queryStructure->getElement(QueryStructure::ORDER_BY))) { |
|
79 | + return 'ORDER BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::ORDER_BY), ', '); |
|
80 | + } |
|
78 | 81 | |
79 | 82 | return ''; |
80 | 83 | } |
@@ -14,125 +14,125 @@ |
||
14 | 14 | trait Join |
15 | 15 | { |
16 | 16 | |
17 | - use Objects; |
|
18 | - |
|
19 | - |
|
20 | - /** |
|
21 | - * @param $tableJoin |
|
22 | - * @param $onLeft |
|
23 | - * @param null $onRight |
|
24 | - * @return $this |
|
25 | - */ |
|
26 | - public function innerJoin($tableJoin, $onLeft, $onRight = null) |
|
27 | - { |
|
28 | - return $this->makeJoin('INNER JOIN', $tableJoin, $onLeft, $onRight); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @param $tableJoin |
|
33 | - * @param $onLeft |
|
34 | - * @param null $onRight |
|
35 | - * @return $this |
|
36 | - */ |
|
37 | - public function leftJoin($tableJoin, $onLeft, $onRight = null) |
|
38 | - { |
|
39 | - return $this->makeJoin('LEFT JOIN', $tableJoin, $onLeft, $onRight); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param $tableJoin |
|
44 | - * @param $onLeft |
|
45 | - * @param null $onRight |
|
46 | - * @return $this |
|
47 | - */ |
|
48 | - public function leftOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
49 | - { |
|
50 | - return $this->makeJoin('LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param $tableJoin |
|
55 | - * @param $onLeft |
|
56 | - * @param null $onRight |
|
57 | - * @return $this |
|
58 | - */ |
|
59 | - public function rightJoin($tableJoin, $onLeft, $onRight = null) |
|
60 | - { |
|
61 | - return $this->makeJoin('RIGHT JOIN', $tableJoin, $onLeft, $onRight); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param $tableJoin |
|
66 | - * @param $onLeft |
|
67 | - * @param null $onRight |
|
68 | - * @return $this |
|
69 | - */ |
|
70 | - public function rightOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
71 | - { |
|
72 | - return $this->makeJoin('RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param $tableJoin |
|
77 | - * @param $onLeft |
|
78 | - * @param null $onRight |
|
79 | - * @return $this |
|
80 | - */ |
|
81 | - public function fullJoin($tableJoin, $onLeft, $onRight = null) |
|
82 | - { |
|
83 | - return $this->makeJoin('FULL JOIN', $tableJoin, $onLeft, $onRight); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @param $tableJoin |
|
88 | - * @param $onLeft |
|
89 | - * @param null $onRight |
|
90 | - * @return $this |
|
91 | - */ |
|
92 | - public function fullOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
93 | - { |
|
94 | - return $this->makeJoin('FULL OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param $stringJoin |
|
99 | - * @return $this |
|
100 | - */ |
|
101 | - public function join($stringJoin) |
|
102 | - { |
|
103 | - $this->queryStructure->setElement(QueryStructure::JOIN, $stringJoin); |
|
104 | - |
|
105 | - return $this; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param $typeJoin |
|
110 | - * @param $tableJoin |
|
111 | - * @param $onLeft |
|
112 | - * @param null $onRight |
|
113 | - * @return $this |
|
114 | - */ |
|
115 | - private function makeJoin($typeJoin, $tableJoin, $onLeft, $onRight = null) |
|
116 | - { |
|
117 | - $join = $typeJoin . ' ' . $tableJoin; |
|
118 | - |
|
119 | - if (is_null($onRight)) |
|
120 | - $join .= " USING ( $onLeft )"; else |
|
121 | - $join .= " ON $onLeft = $onRight"; |
|
122 | - |
|
123 | - $this->queryStructure->setElement(QueryStructure::JOIN, $join); |
|
124 | - |
|
125 | - return $this; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - private function getJoinSyntax() |
|
132 | - { |
|
133 | - $joinString = implode(' ', $this->queryStructure->getElement(QueryStructure::JOIN)); |
|
134 | - |
|
135 | - return QueryHelper::clearMultipleSpaces($joinString); |
|
136 | - } |
|
17 | + use Objects; |
|
18 | + |
|
19 | + |
|
20 | + /** |
|
21 | + * @param $tableJoin |
|
22 | + * @param $onLeft |
|
23 | + * @param null $onRight |
|
24 | + * @return $this |
|
25 | + */ |
|
26 | + public function innerJoin($tableJoin, $onLeft, $onRight = null) |
|
27 | + { |
|
28 | + return $this->makeJoin('INNER JOIN', $tableJoin, $onLeft, $onRight); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @param $tableJoin |
|
33 | + * @param $onLeft |
|
34 | + * @param null $onRight |
|
35 | + * @return $this |
|
36 | + */ |
|
37 | + public function leftJoin($tableJoin, $onLeft, $onRight = null) |
|
38 | + { |
|
39 | + return $this->makeJoin('LEFT JOIN', $tableJoin, $onLeft, $onRight); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param $tableJoin |
|
44 | + * @param $onLeft |
|
45 | + * @param null $onRight |
|
46 | + * @return $this |
|
47 | + */ |
|
48 | + public function leftOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
49 | + { |
|
50 | + return $this->makeJoin('LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param $tableJoin |
|
55 | + * @param $onLeft |
|
56 | + * @param null $onRight |
|
57 | + * @return $this |
|
58 | + */ |
|
59 | + public function rightJoin($tableJoin, $onLeft, $onRight = null) |
|
60 | + { |
|
61 | + return $this->makeJoin('RIGHT JOIN', $tableJoin, $onLeft, $onRight); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param $tableJoin |
|
66 | + * @param $onLeft |
|
67 | + * @param null $onRight |
|
68 | + * @return $this |
|
69 | + */ |
|
70 | + public function rightOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
71 | + { |
|
72 | + return $this->makeJoin('RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param $tableJoin |
|
77 | + * @param $onLeft |
|
78 | + * @param null $onRight |
|
79 | + * @return $this |
|
80 | + */ |
|
81 | + public function fullJoin($tableJoin, $onLeft, $onRight = null) |
|
82 | + { |
|
83 | + return $this->makeJoin('FULL JOIN', $tableJoin, $onLeft, $onRight); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @param $tableJoin |
|
88 | + * @param $onLeft |
|
89 | + * @param null $onRight |
|
90 | + * @return $this |
|
91 | + */ |
|
92 | + public function fullOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
93 | + { |
|
94 | + return $this->makeJoin('FULL OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param $stringJoin |
|
99 | + * @return $this |
|
100 | + */ |
|
101 | + public function join($stringJoin) |
|
102 | + { |
|
103 | + $this->queryStructure->setElement(QueryStructure::JOIN, $stringJoin); |
|
104 | + |
|
105 | + return $this; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param $typeJoin |
|
110 | + * @param $tableJoin |
|
111 | + * @param $onLeft |
|
112 | + * @param null $onRight |
|
113 | + * @return $this |
|
114 | + */ |
|
115 | + private function makeJoin($typeJoin, $tableJoin, $onLeft, $onRight = null) |
|
116 | + { |
|
117 | + $join = $typeJoin . ' ' . $tableJoin; |
|
118 | + |
|
119 | + if (is_null($onRight)) |
|
120 | + $join .= " USING ( $onLeft )"; else |
|
121 | + $join .= " ON $onLeft = $onRight"; |
|
122 | + |
|
123 | + $this->queryStructure->setElement(QueryStructure::JOIN, $join); |
|
124 | + |
|
125 | + return $this; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + private function getJoinSyntax() |
|
132 | + { |
|
133 | + $joinString = implode(' ', $this->queryStructure->getElement(QueryStructure::JOIN)); |
|
134 | + |
|
135 | + return QueryHelper::clearMultipleSpaces($joinString); |
|
136 | + } |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * @param null $onRight |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function innerJoin($tableJoin, $onLeft, $onRight = null) |
|
26 | + public function innerJoin( $tableJoin, $onLeft, $onRight = null ) |
|
27 | 27 | { |
28 | - return $this->makeJoin('INNER JOIN', $tableJoin, $onLeft, $onRight); |
|
28 | + return $this->makeJoin( 'INNER JOIN', $tableJoin, $onLeft, $onRight ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * @param null $onRight |
35 | 35 | * @return $this |
36 | 36 | */ |
37 | - public function leftJoin($tableJoin, $onLeft, $onRight = null) |
|
37 | + public function leftJoin( $tableJoin, $onLeft, $onRight = null ) |
|
38 | 38 | { |
39 | - return $this->makeJoin('LEFT JOIN', $tableJoin, $onLeft, $onRight); |
|
39 | + return $this->makeJoin( 'LEFT JOIN', $tableJoin, $onLeft, $onRight ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param null $onRight |
46 | 46 | * @return $this |
47 | 47 | */ |
48 | - public function leftOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
48 | + public function leftOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
49 | 49 | { |
50 | - return $this->makeJoin('LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
50 | + return $this->makeJoin( 'LEFT OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @param null $onRight |
57 | 57 | * @return $this |
58 | 58 | */ |
59 | - public function rightJoin($tableJoin, $onLeft, $onRight = null) |
|
59 | + public function rightJoin( $tableJoin, $onLeft, $onRight = null ) |
|
60 | 60 | { |
61 | - return $this->makeJoin('RIGHT JOIN', $tableJoin, $onLeft, $onRight); |
|
61 | + return $this->makeJoin( 'RIGHT JOIN', $tableJoin, $onLeft, $onRight ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @param null $onRight |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function rightOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
70 | + public function rightOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
71 | 71 | { |
72 | - return $this->makeJoin('RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
72 | + return $this->makeJoin( 'RIGHT OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param null $onRight |
79 | 79 | * @return $this |
80 | 80 | */ |
81 | - public function fullJoin($tableJoin, $onLeft, $onRight = null) |
|
81 | + public function fullJoin( $tableJoin, $onLeft, $onRight = null ) |
|
82 | 82 | { |
83 | - return $this->makeJoin('FULL JOIN', $tableJoin, $onLeft, $onRight); |
|
83 | + return $this->makeJoin( 'FULL JOIN', $tableJoin, $onLeft, $onRight ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | * @param null $onRight |
90 | 90 | * @return $this |
91 | 91 | */ |
92 | - public function fullOuterJoin($tableJoin, $onLeft, $onRight = null) |
|
92 | + public function fullOuterJoin( $tableJoin, $onLeft, $onRight = null ) |
|
93 | 93 | { |
94 | - return $this->makeJoin('FULL OUTER JOIN', $tableJoin, $onLeft, $onRight); |
|
94 | + return $this->makeJoin( 'FULL OUTER JOIN', $tableJoin, $onLeft, $onRight ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @param $stringJoin |
99 | 99 | * @return $this |
100 | 100 | */ |
101 | - public function join($stringJoin) |
|
101 | + public function join( $stringJoin ) |
|
102 | 102 | { |
103 | - $this->queryStructure->setElement(QueryStructure::JOIN, $stringJoin); |
|
103 | + $this->queryStructure->setElement( QueryStructure::JOIN, $stringJoin ); |
|
104 | 104 | |
105 | 105 | return $this; |
106 | 106 | } |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | * @param null $onRight |
113 | 113 | * @return $this |
114 | 114 | */ |
115 | - private function makeJoin($typeJoin, $tableJoin, $onLeft, $onRight = null) |
|
115 | + private function makeJoin( $typeJoin, $tableJoin, $onLeft, $onRight = null ) |
|
116 | 116 | { |
117 | 117 | $join = $typeJoin . ' ' . $tableJoin; |
118 | 118 | |
119 | - if (is_null($onRight)) |
|
119 | + if ( is_null( $onRight ) ) |
|
120 | 120 | $join .= " USING ( $onLeft )"; else |
121 | 121 | $join .= " ON $onLeft = $onRight"; |
122 | 122 | |
123 | - $this->queryStructure->setElement(QueryStructure::JOIN, $join); |
|
123 | + $this->queryStructure->setElement( QueryStructure::JOIN, $join ); |
|
124 | 124 | |
125 | 125 | return $this; |
126 | 126 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private function getJoinSyntax() |
132 | 132 | { |
133 | - $joinString = implode(' ', $this->queryStructure->getElement(QueryStructure::JOIN)); |
|
133 | + $joinString = implode( ' ', $this->queryStructure->getElement( QueryStructure::JOIN ) ); |
|
134 | 134 | |
135 | - return QueryHelper::clearMultipleSpaces($joinString); |
|
135 | + return QueryHelper::clearMultipleSpaces( $joinString ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -116,9 +116,11 @@ |
||
116 | 116 | { |
117 | 117 | $join = $typeJoin . ' ' . $tableJoin; |
118 | 118 | |
119 | - if (is_null($onRight)) |
|
120 | - $join .= " USING ( $onLeft )"; else |
|
121 | - $join .= " ON $onLeft = $onRight"; |
|
119 | + if (is_null($onRight)) { |
|
120 | + $join .= " USING ( $onLeft )"; |
|
121 | + } else { |
|
122 | + $join .= " ON $onLeft = $onRight"; |
|
123 | + } |
|
122 | 124 | |
123 | 125 | $this->queryStructure->setElement(QueryStructure::JOIN, $join); |
124 | 126 |
@@ -18,52 +18,52 @@ |
||
18 | 18 | trait TableValidation |
19 | 19 | { |
20 | 20 | |
21 | - private function validateTable($table) |
|
22 | - { |
|
23 | - switch (gettype($table)) { |
|
24 | - |
|
25 | - case QueryStructure::ELEMENT_TYPE_STRING: |
|
26 | - $table = $this->validateTableName($table); |
|
27 | - break; |
|
28 | - case QueryStructure::ELEMENT_TYPE_OBJECT: |
|
29 | - $table = $this->validateTableSubQuery($table); |
|
30 | - break; |
|
31 | - default: |
|
32 | - throw new QueryException('Invalid table type parameter: ' . gettype($table), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
33 | - |
|
34 | - } |
|
35 | - |
|
36 | - return $table; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @param $table |
|
41 | - * @return mixed|string |
|
42 | - * @throws QueryException |
|
43 | - */ |
|
44 | - private function validateTableName($table) |
|
45 | - { |
|
46 | - $table = trim($table); |
|
47 | - |
|
48 | - if ('' === $table) |
|
49 | - throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
50 | - |
|
51 | - if (DbConfig::getInstance()->useTablePrefix()) |
|
52 | - $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
53 | - |
|
54 | - return $table; |
|
55 | - } |
|
56 | - |
|
57 | - private function validateTableSubQuery($table) |
|
58 | - { |
|
59 | - if ($this->statement !== QueryStatement::QUERY_STATEMENT_SELECT) |
|
60 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
61 | - |
|
62 | - if (!is_a($table, QuerySelect::class)) |
|
63 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
64 | - |
|
65 | - return $table; |
|
66 | - } |
|
21 | + private function validateTable($table) |
|
22 | + { |
|
23 | + switch (gettype($table)) { |
|
24 | + |
|
25 | + case QueryStructure::ELEMENT_TYPE_STRING: |
|
26 | + $table = $this->validateTableName($table); |
|
27 | + break; |
|
28 | + case QueryStructure::ELEMENT_TYPE_OBJECT: |
|
29 | + $table = $this->validateTableSubQuery($table); |
|
30 | + break; |
|
31 | + default: |
|
32 | + throw new QueryException('Invalid table type parameter: ' . gettype($table), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
33 | + |
|
34 | + } |
|
35 | + |
|
36 | + return $table; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @param $table |
|
41 | + * @return mixed|string |
|
42 | + * @throws QueryException |
|
43 | + */ |
|
44 | + private function validateTableName($table) |
|
45 | + { |
|
46 | + $table = trim($table); |
|
47 | + |
|
48 | + if ('' === $table) |
|
49 | + throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
50 | + |
|
51 | + if (DbConfig::getInstance()->useTablePrefix()) |
|
52 | + $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
53 | + |
|
54 | + return $table; |
|
55 | + } |
|
56 | + |
|
57 | + private function validateTableSubQuery($table) |
|
58 | + { |
|
59 | + if ($this->statement !== QueryStatement::QUERY_STATEMENT_SELECT) |
|
60 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
61 | + |
|
62 | + if (!is_a($table, QuerySelect::class)) |
|
63 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
64 | + |
|
65 | + return $table; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | trait TableValidation |
19 | 19 | { |
20 | 20 | |
21 | - private function validateTable($table) |
|
21 | + private function validateTable( $table ) |
|
22 | 22 | { |
23 | - switch (gettype($table)) { |
|
23 | + switch ( gettype( $table ) ) { |
|
24 | 24 | |
25 | 25 | case QueryStructure::ELEMENT_TYPE_STRING: |
26 | - $table = $this->validateTableName($table); |
|
26 | + $table = $this->validateTableName( $table ); |
|
27 | 27 | break; |
28 | 28 | case QueryStructure::ELEMENT_TYPE_OBJECT: |
29 | - $table = $this->validateTableSubQuery($table); |
|
29 | + $table = $this->validateTableSubQuery( $table ); |
|
30 | 30 | break; |
31 | 31 | default: |
32 | - throw new QueryException('Invalid table type parameter: ' . gettype($table), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
32 | + throw new QueryException( 'Invalid table type parameter: ' . gettype( $table ), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
33 | 33 | |
34 | 34 | } |
35 | 35 | |
@@ -41,26 +41,26 @@ discard block |
||
41 | 41 | * @return mixed|string |
42 | 42 | * @throws QueryException |
43 | 43 | */ |
44 | - private function validateTableName($table) |
|
44 | + private function validateTableName( $table ) |
|
45 | 45 | { |
46 | - $table = trim($table); |
|
46 | + $table = trim( $table ); |
|
47 | 47 | |
48 | - if ('' === $table) |
|
49 | - throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
48 | + if ( '' === $table ) |
|
49 | + throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
50 | 50 | |
51 | - if (DbConfig::getInstance()->useTablePrefix()) |
|
52 | - $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
51 | + if ( DbConfig::getInstance()->useTablePrefix() ) |
|
52 | + $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
53 | 53 | |
54 | 54 | return $table; |
55 | 55 | } |
56 | 56 | |
57 | - private function validateTableSubQuery($table) |
|
57 | + private function validateTableSubQuery( $table ) |
|
58 | 58 | { |
59 | - if ($this->statement !== QueryStatement::QUERY_STATEMENT_SELECT) |
|
60 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
59 | + if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) |
|
60 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
61 | 61 | |
62 | - if (!is_a($table, QuerySelect::class)) |
|
63 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
62 | + if ( !is_a( $table, QuerySelect::class ) ) |
|
63 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
64 | 64 | |
65 | 65 | return $table; |
66 | 66 | } |
@@ -45,22 +45,26 @@ |
||
45 | 45 | { |
46 | 46 | $table = trim($table); |
47 | 47 | |
48 | - if ('' === $table) |
|
49 | - throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
48 | + if ('' === $table) { |
|
49 | + throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
50 | + } |
|
50 | 51 | |
51 | - if (DbConfig::getInstance()->useTablePrefix()) |
|
52 | - $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
52 | + if (DbConfig::getInstance()->useTablePrefix()) { |
|
53 | + $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | return $table; |
55 | 57 | } |
56 | 58 | |
57 | 59 | private function validateTableSubQuery($table) |
58 | 60 | { |
59 | - if ($this->statement !== QueryStatement::QUERY_STATEMENT_SELECT) |
|
60 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
61 | + if ($this->statement !== QueryStatement::QUERY_STATEMENT_SELECT) { |
|
62 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
63 | + } |
|
61 | 64 | |
62 | - if (!is_a($table, QuerySelect::class)) |
|
63 | - throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
65 | + if (!is_a($table, QuerySelect::class)) { |
|
66 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
67 | + } |
|
64 | 68 | |
65 | 69 | return $table; |
66 | 70 | } |
@@ -13,349 +13,349 @@ |
||
13 | 13 | trait Where |
14 | 14 | { |
15 | 15 | |
16 | - use Objects; |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * @param $field |
|
21 | - * @param $value |
|
22 | - * @param $glue |
|
23 | - * @return $this |
|
24 | - */ |
|
25 | - public function whereEqual($field, $value, $glue = 'AND') |
|
26 | - { |
|
27 | - return $this->where(array($field, $value, '='), $glue); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * @param $field |
|
32 | - * @param $value |
|
33 | - * @return $this |
|
34 | - */ |
|
35 | - public function orWhereEqual($field, $value) |
|
36 | - { |
|
37 | - return $this->where(array($field, $value, '='), 'OR'); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @param $field |
|
42 | - * @param $value |
|
43 | - * @param string $glue |
|
44 | - * @return $this |
|
45 | - */ |
|
46 | - public function whereNotEqual($field, $value, $glue = 'AND') |
|
47 | - { |
|
48 | - return $this->where(array($field, $value, '<>'), $glue); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $field |
|
53 | - * @param $value |
|
54 | - * @return $this |
|
55 | - */ |
|
56 | - public function orWhereNotEqual($field, $value) |
|
57 | - { |
|
58 | - return $this->where(array($field, $value, '<>'), 'OR'); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param $field |
|
63 | - * @param $value |
|
64 | - * @param string $glue |
|
65 | - * @return $this |
|
66 | - */ |
|
67 | - public function whereLessThan($field, $value, $glue = 'AND') |
|
68 | - { |
|
69 | - return $this->where(array($field, $value, '<'), $glue); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param $field |
|
74 | - * @param $value |
|
75 | - * @return $this |
|
76 | - */ |
|
77 | - public function orWhereLessThan($field, $value) |
|
78 | - { |
|
79 | - return $this->where(array($field, $value, '<'), 'OR'); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @param $field |
|
84 | - * @param $value |
|
85 | - * @param string $glue |
|
86 | - * @return $this |
|
87 | - */ |
|
88 | - public function whereLessThanOrEqual($field, $value, $glue = 'AND') |
|
89 | - { |
|
90 | - return $this->where(array($field, $value, '<='), $glue); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param $field |
|
95 | - * @param $value |
|
96 | - * @return $this |
|
97 | - */ |
|
98 | - public function orWhereLessThanOrEqual($field, $value) |
|
99 | - { |
|
100 | - return $this->where(array($field, $value, '<='), 'OR'); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param $field |
|
105 | - * @param $value |
|
106 | - * @param string $glue |
|
107 | - * @return $this |
|
108 | - */ |
|
109 | - public function whereGreaterThan($field, $value, $glue = 'AND') |
|
110 | - { |
|
111 | - return $this->where(array($field, $value, '>'), $glue); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param $field |
|
116 | - * @param $value |
|
117 | - * @return $this |
|
118 | - */ |
|
119 | - public function orWhereGreaterThan($field, $value) |
|
120 | - { |
|
121 | - return $this->where(array($field, $value, '>'), 'OR'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @param $field |
|
126 | - * @param $value |
|
127 | - * @param string $glue |
|
128 | - * @return $this |
|
129 | - */ |
|
130 | - public function whereGreaterThanOrEqual($field, $value, $glue = 'AND') |
|
131 | - { |
|
132 | - return $this->where(array($field, $value, '>='), $glue); |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @param $field |
|
137 | - * @param $value |
|
138 | - * @return $this |
|
139 | - */ |
|
140 | - public function orWhereGreaterThanOrEqual($field, $value) |
|
141 | - { |
|
142 | - return $this->where(array($field, $value, '>='), 'OR'); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * @param $field |
|
147 | - * @param $value |
|
148 | - * @param string $glue |
|
149 | - * @return $this |
|
150 | - */ |
|
151 | - public function whereLike($field, $value, $glue = 'AND') |
|
152 | - { |
|
153 | - return $this->where(array($field, $value, 'LIKE'), $glue); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param $field |
|
158 | - * @param $value |
|
159 | - * @return $this |
|
160 | - */ |
|
161 | - public function orWhereLike($field, $value) |
|
162 | - { |
|
163 | - return $this->where(array($field, $value, 'LIKE'), 'OR'); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @param $field |
|
168 | - * @param $value |
|
169 | - * @param string $glue |
|
170 | - * @return $this |
|
171 | - */ |
|
172 | - public function whereNotLike($field, $value, $glue = 'AND') |
|
173 | - { |
|
174 | - return $this->where(array($field, $value, 'NOT LIKE'), $glue); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param $field |
|
179 | - * @param $value |
|
180 | - * @return $this |
|
181 | - */ |
|
182 | - public function orWhereNotLike($field, $value) |
|
183 | - { |
|
184 | - return $this->where(array($field, $value, 'NOT LIKE'), 'OR'); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * @param $field |
|
189 | - * @param $min |
|
190 | - * @param $max |
|
191 | - * @param string $glue |
|
192 | - * @return $this |
|
193 | - */ |
|
194 | - public function whereBetween($field, $min, $max, $glue = 'AND') |
|
195 | - { |
|
196 | - return $this->where(array($field, array($min, $max), 'BETWEEN'), $glue); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @param $field |
|
201 | - * @param $min |
|
202 | - * @param $max |
|
203 | - * @return $this |
|
204 | - */ |
|
205 | - public function orWhereBetween($field, $min, $max) |
|
206 | - { |
|
207 | - return $this->where(array($field, array($min, $max), 'BETWEEN'), 'OR'); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param $field |
|
212 | - * @param $min |
|
213 | - * @param $max |
|
214 | - * @param string $glue |
|
215 | - * @return $this |
|
216 | - */ |
|
217 | - public function whereNotBetween($field, $min, $max, $glue = 'AND') |
|
218 | - { |
|
219 | - return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), $glue); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @param $field |
|
224 | - * @param $min |
|
225 | - * @param $max |
|
226 | - * @return $this |
|
227 | - */ |
|
228 | - public function orWhereNotBetween($field, $min, $max) |
|
229 | - { |
|
230 | - return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), 'OR'); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * @param $field |
|
235 | - * @param $value |
|
236 | - * @param string $glue |
|
237 | - * @return $this |
|
238 | - */ |
|
239 | - public function whereIn($field, $value, $glue = 'AND') |
|
240 | - { |
|
241 | - return $this->where(array($field, $value, 'IN'), $glue); |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * @param $field |
|
246 | - * @param $value |
|
247 | - * @return $this |
|
248 | - */ |
|
249 | - public function orWhereIn($field, $value) |
|
250 | - { |
|
251 | - return $this->where(array($field, $value, 'IN'), 'OR'); |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * @param $field |
|
256 | - * @param $value |
|
257 | - * @param string $glue |
|
258 | - * @return $this |
|
259 | - */ |
|
260 | - public function whereNotIn($field, $value, $glue = 'AND') |
|
261 | - { |
|
262 | - return $this->where(array($field, $value, 'NOT IN'), $glue); |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * @param $field |
|
267 | - * @param $value |
|
268 | - * @return $this |
|
269 | - */ |
|
270 | - public function orWhereNotIn($field, $value) |
|
271 | - { |
|
272 | - return $this->where(array($field, $value, 'NOT IN'), 'OR'); |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * @param $whereString |
|
277 | - * @param array $bindParams |
|
278 | - * @param string $glue |
|
279 | - * @return $this |
|
280 | - */ |
|
281 | - public function whereExpression($whereString, array $bindParams = [], $glue = 'AND') |
|
282 | - { |
|
283 | - $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
284 | - |
|
285 | - return $this->where($whereString, $glue); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * @param $whereString |
|
290 | - * @param array $bindParams |
|
291 | - * @return $this |
|
292 | - */ |
|
293 | - public function orWhereExpression($whereString, array $bindParams = []) |
|
294 | - { |
|
295 | - $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
296 | - |
|
297 | - return $this->where($whereString, 'OR'); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * @return $this |
|
302 | - */ |
|
303 | - public function whereInvertResult() |
|
304 | - { |
|
305 | - $this->queryStructure->setElement(QueryStructure::WHERE_INVERT, 1); |
|
306 | - |
|
307 | - return $this; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * @param string $glue |
|
312 | - * @return $this |
|
313 | - */ |
|
314 | - public function whereGroup($glue = 'AND') |
|
315 | - { |
|
316 | - $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group')); |
|
317 | - |
|
318 | - return $this; |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * @return $this |
|
323 | - */ |
|
324 | - public function orWhereGroup() |
|
325 | - { |
|
326 | - return $this->whereGroup('OR'); |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * @return $this |
|
331 | - */ |
|
332 | - public function whereGroupEnd() |
|
333 | - { |
|
334 | - $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => '', 'body' => ')', 'type' => 'end_where_group')); |
|
335 | - |
|
336 | - return $this; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * @return $this |
|
341 | - */ |
|
342 | - public function ignoreWhereTrigger() |
|
343 | - { |
|
344 | - $this->queryStructure->setElement(QueryStructure::WHERE_TRIGGER, 0); |
|
345 | - |
|
346 | - return $this; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @param string|array $param |
|
352 | - * @param string $glue |
|
353 | - * @return $this |
|
354 | - */ |
|
355 | - private function where($param, $glue = 'AND') |
|
356 | - { |
|
357 | - return $this->/** @scrutinizer ignore-call */ |
|
358 | - createCondition($param, $glue, QueryStructure::WHERE); |
|
359 | - } |
|
16 | + use Objects; |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * @param $field |
|
21 | + * @param $value |
|
22 | + * @param $glue |
|
23 | + * @return $this |
|
24 | + */ |
|
25 | + public function whereEqual($field, $value, $glue = 'AND') |
|
26 | + { |
|
27 | + return $this->where(array($field, $value, '='), $glue); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * @param $field |
|
32 | + * @param $value |
|
33 | + * @return $this |
|
34 | + */ |
|
35 | + public function orWhereEqual($field, $value) |
|
36 | + { |
|
37 | + return $this->where(array($field, $value, '='), 'OR'); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @param $field |
|
42 | + * @param $value |
|
43 | + * @param string $glue |
|
44 | + * @return $this |
|
45 | + */ |
|
46 | + public function whereNotEqual($field, $value, $glue = 'AND') |
|
47 | + { |
|
48 | + return $this->where(array($field, $value, '<>'), $glue); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $field |
|
53 | + * @param $value |
|
54 | + * @return $this |
|
55 | + */ |
|
56 | + public function orWhereNotEqual($field, $value) |
|
57 | + { |
|
58 | + return $this->where(array($field, $value, '<>'), 'OR'); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param $field |
|
63 | + * @param $value |
|
64 | + * @param string $glue |
|
65 | + * @return $this |
|
66 | + */ |
|
67 | + public function whereLessThan($field, $value, $glue = 'AND') |
|
68 | + { |
|
69 | + return $this->where(array($field, $value, '<'), $glue); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param $field |
|
74 | + * @param $value |
|
75 | + * @return $this |
|
76 | + */ |
|
77 | + public function orWhereLessThan($field, $value) |
|
78 | + { |
|
79 | + return $this->where(array($field, $value, '<'), 'OR'); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @param $field |
|
84 | + * @param $value |
|
85 | + * @param string $glue |
|
86 | + * @return $this |
|
87 | + */ |
|
88 | + public function whereLessThanOrEqual($field, $value, $glue = 'AND') |
|
89 | + { |
|
90 | + return $this->where(array($field, $value, '<='), $glue); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param $field |
|
95 | + * @param $value |
|
96 | + * @return $this |
|
97 | + */ |
|
98 | + public function orWhereLessThanOrEqual($field, $value) |
|
99 | + { |
|
100 | + return $this->where(array($field, $value, '<='), 'OR'); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param $field |
|
105 | + * @param $value |
|
106 | + * @param string $glue |
|
107 | + * @return $this |
|
108 | + */ |
|
109 | + public function whereGreaterThan($field, $value, $glue = 'AND') |
|
110 | + { |
|
111 | + return $this->where(array($field, $value, '>'), $glue); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param $field |
|
116 | + * @param $value |
|
117 | + * @return $this |
|
118 | + */ |
|
119 | + public function orWhereGreaterThan($field, $value) |
|
120 | + { |
|
121 | + return $this->where(array($field, $value, '>'), 'OR'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @param $field |
|
126 | + * @param $value |
|
127 | + * @param string $glue |
|
128 | + * @return $this |
|
129 | + */ |
|
130 | + public function whereGreaterThanOrEqual($field, $value, $glue = 'AND') |
|
131 | + { |
|
132 | + return $this->where(array($field, $value, '>='), $glue); |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @param $field |
|
137 | + * @param $value |
|
138 | + * @return $this |
|
139 | + */ |
|
140 | + public function orWhereGreaterThanOrEqual($field, $value) |
|
141 | + { |
|
142 | + return $this->where(array($field, $value, '>='), 'OR'); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * @param $field |
|
147 | + * @param $value |
|
148 | + * @param string $glue |
|
149 | + * @return $this |
|
150 | + */ |
|
151 | + public function whereLike($field, $value, $glue = 'AND') |
|
152 | + { |
|
153 | + return $this->where(array($field, $value, 'LIKE'), $glue); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * @param $field |
|
158 | + * @param $value |
|
159 | + * @return $this |
|
160 | + */ |
|
161 | + public function orWhereLike($field, $value) |
|
162 | + { |
|
163 | + return $this->where(array($field, $value, 'LIKE'), 'OR'); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @param $field |
|
168 | + * @param $value |
|
169 | + * @param string $glue |
|
170 | + * @return $this |
|
171 | + */ |
|
172 | + public function whereNotLike($field, $value, $glue = 'AND') |
|
173 | + { |
|
174 | + return $this->where(array($field, $value, 'NOT LIKE'), $glue); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param $field |
|
179 | + * @param $value |
|
180 | + * @return $this |
|
181 | + */ |
|
182 | + public function orWhereNotLike($field, $value) |
|
183 | + { |
|
184 | + return $this->where(array($field, $value, 'NOT LIKE'), 'OR'); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * @param $field |
|
189 | + * @param $min |
|
190 | + * @param $max |
|
191 | + * @param string $glue |
|
192 | + * @return $this |
|
193 | + */ |
|
194 | + public function whereBetween($field, $min, $max, $glue = 'AND') |
|
195 | + { |
|
196 | + return $this->where(array($field, array($min, $max), 'BETWEEN'), $glue); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @param $field |
|
201 | + * @param $min |
|
202 | + * @param $max |
|
203 | + * @return $this |
|
204 | + */ |
|
205 | + public function orWhereBetween($field, $min, $max) |
|
206 | + { |
|
207 | + return $this->where(array($field, array($min, $max), 'BETWEEN'), 'OR'); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param $field |
|
212 | + * @param $min |
|
213 | + * @param $max |
|
214 | + * @param string $glue |
|
215 | + * @return $this |
|
216 | + */ |
|
217 | + public function whereNotBetween($field, $min, $max, $glue = 'AND') |
|
218 | + { |
|
219 | + return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), $glue); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @param $field |
|
224 | + * @param $min |
|
225 | + * @param $max |
|
226 | + * @return $this |
|
227 | + */ |
|
228 | + public function orWhereNotBetween($field, $min, $max) |
|
229 | + { |
|
230 | + return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), 'OR'); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * @param $field |
|
235 | + * @param $value |
|
236 | + * @param string $glue |
|
237 | + * @return $this |
|
238 | + */ |
|
239 | + public function whereIn($field, $value, $glue = 'AND') |
|
240 | + { |
|
241 | + return $this->where(array($field, $value, 'IN'), $glue); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * @param $field |
|
246 | + * @param $value |
|
247 | + * @return $this |
|
248 | + */ |
|
249 | + public function orWhereIn($field, $value) |
|
250 | + { |
|
251 | + return $this->where(array($field, $value, 'IN'), 'OR'); |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * @param $field |
|
256 | + * @param $value |
|
257 | + * @param string $glue |
|
258 | + * @return $this |
|
259 | + */ |
|
260 | + public function whereNotIn($field, $value, $glue = 'AND') |
|
261 | + { |
|
262 | + return $this->where(array($field, $value, 'NOT IN'), $glue); |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * @param $field |
|
267 | + * @param $value |
|
268 | + * @return $this |
|
269 | + */ |
|
270 | + public function orWhereNotIn($field, $value) |
|
271 | + { |
|
272 | + return $this->where(array($field, $value, 'NOT IN'), 'OR'); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * @param $whereString |
|
277 | + * @param array $bindParams |
|
278 | + * @param string $glue |
|
279 | + * @return $this |
|
280 | + */ |
|
281 | + public function whereExpression($whereString, array $bindParams = [], $glue = 'AND') |
|
282 | + { |
|
283 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
284 | + |
|
285 | + return $this->where($whereString, $glue); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * @param $whereString |
|
290 | + * @param array $bindParams |
|
291 | + * @return $this |
|
292 | + */ |
|
293 | + public function orWhereExpression($whereString, array $bindParams = []) |
|
294 | + { |
|
295 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
296 | + |
|
297 | + return $this->where($whereString, 'OR'); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * @return $this |
|
302 | + */ |
|
303 | + public function whereInvertResult() |
|
304 | + { |
|
305 | + $this->queryStructure->setElement(QueryStructure::WHERE_INVERT, 1); |
|
306 | + |
|
307 | + return $this; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * @param string $glue |
|
312 | + * @return $this |
|
313 | + */ |
|
314 | + public function whereGroup($glue = 'AND') |
|
315 | + { |
|
316 | + $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group')); |
|
317 | + |
|
318 | + return $this; |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * @return $this |
|
323 | + */ |
|
324 | + public function orWhereGroup() |
|
325 | + { |
|
326 | + return $this->whereGroup('OR'); |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * @return $this |
|
331 | + */ |
|
332 | + public function whereGroupEnd() |
|
333 | + { |
|
334 | + $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => '', 'body' => ')', 'type' => 'end_where_group')); |
|
335 | + |
|
336 | + return $this; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * @return $this |
|
341 | + */ |
|
342 | + public function ignoreWhereTrigger() |
|
343 | + { |
|
344 | + $this->queryStructure->setElement(QueryStructure::WHERE_TRIGGER, 0); |
|
345 | + |
|
346 | + return $this; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @param string|array $param |
|
352 | + * @param string $glue |
|
353 | + * @return $this |
|
354 | + */ |
|
355 | + private function where($param, $glue = 'AND') |
|
356 | + { |
|
357 | + return $this->/** @scrutinizer ignore-call */ |
|
358 | + createCondition($param, $glue, QueryStructure::WHERE); |
|
359 | + } |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | \ No newline at end of file |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param $glue |
23 | 23 | * @return $this |
24 | 24 | */ |
25 | - public function whereEqual($field, $value, $glue = 'AND') |
|
25 | + public function whereEqual( $field, $value, $glue = 'AND' ) |
|
26 | 26 | { |
27 | - return $this->where(array($field, $value, '='), $glue); |
|
27 | + return $this->where( array( $field, $value, '=' ), $glue ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @param $value |
33 | 33 | * @return $this |
34 | 34 | */ |
35 | - public function orWhereEqual($field, $value) |
|
35 | + public function orWhereEqual( $field, $value ) |
|
36 | 36 | { |
37 | - return $this->where(array($field, $value, '='), 'OR'); |
|
37 | + return $this->where( array( $field, $value, '=' ), 'OR' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @param string $glue |
44 | 44 | * @return $this |
45 | 45 | */ |
46 | - public function whereNotEqual($field, $value, $glue = 'AND') |
|
46 | + public function whereNotEqual( $field, $value, $glue = 'AND' ) |
|
47 | 47 | { |
48 | - return $this->where(array($field, $value, '<>'), $glue); |
|
48 | + return $this->where( array( $field, $value, '<>' ), $glue ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @param $value |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function orWhereNotEqual($field, $value) |
|
56 | + public function orWhereNotEqual( $field, $value ) |
|
57 | 57 | { |
58 | - return $this->where(array($field, $value, '<>'), 'OR'); |
|
58 | + return $this->where( array( $field, $value, '<>' ), 'OR' ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param string $glue |
65 | 65 | * @return $this |
66 | 66 | */ |
67 | - public function whereLessThan($field, $value, $glue = 'AND') |
|
67 | + public function whereLessThan( $field, $value, $glue = 'AND' ) |
|
68 | 68 | { |
69 | - return $this->where(array($field, $value, '<'), $glue); |
|
69 | + return $this->where( array( $field, $value, '<' ), $glue ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param $value |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function orWhereLessThan($field, $value) |
|
77 | + public function orWhereLessThan( $field, $value ) |
|
78 | 78 | { |
79 | - return $this->where(array($field, $value, '<'), 'OR'); |
|
79 | + return $this->where( array( $field, $value, '<' ), 'OR' ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param string $glue |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - public function whereLessThanOrEqual($field, $value, $glue = 'AND') |
|
88 | + public function whereLessThanOrEqual( $field, $value, $glue = 'AND' ) |
|
89 | 89 | { |
90 | - return $this->where(array($field, $value, '<='), $glue); |
|
90 | + return $this->where( array( $field, $value, '<=' ), $glue ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param $value |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function orWhereLessThanOrEqual($field, $value) |
|
98 | + public function orWhereLessThanOrEqual( $field, $value ) |
|
99 | 99 | { |
100 | - return $this->where(array($field, $value, '<='), 'OR'); |
|
100 | + return $this->where( array( $field, $value, '<=' ), 'OR' ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param string $glue |
107 | 107 | * @return $this |
108 | 108 | */ |
109 | - public function whereGreaterThan($field, $value, $glue = 'AND') |
|
109 | + public function whereGreaterThan( $field, $value, $glue = 'AND' ) |
|
110 | 110 | { |
111 | - return $this->where(array($field, $value, '>'), $glue); |
|
111 | + return $this->where( array( $field, $value, '>' ), $glue ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param $value |
117 | 117 | * @return $this |
118 | 118 | */ |
119 | - public function orWhereGreaterThan($field, $value) |
|
119 | + public function orWhereGreaterThan( $field, $value ) |
|
120 | 120 | { |
121 | - return $this->where(array($field, $value, '>'), 'OR'); |
|
121 | + return $this->where( array( $field, $value, '>' ), 'OR' ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @param string $glue |
128 | 128 | * @return $this |
129 | 129 | */ |
130 | - public function whereGreaterThanOrEqual($field, $value, $glue = 'AND') |
|
130 | + public function whereGreaterThanOrEqual( $field, $value, $glue = 'AND' ) |
|
131 | 131 | { |
132 | - return $this->where(array($field, $value, '>='), $glue); |
|
132 | + return $this->where( array( $field, $value, '>=' ), $glue ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param $value |
138 | 138 | * @return $this |
139 | 139 | */ |
140 | - public function orWhereGreaterThanOrEqual($field, $value) |
|
140 | + public function orWhereGreaterThanOrEqual( $field, $value ) |
|
141 | 141 | { |
142 | - return $this->where(array($field, $value, '>='), 'OR'); |
|
142 | + return $this->where( array( $field, $value, '>=' ), 'OR' ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param string $glue |
149 | 149 | * @return $this |
150 | 150 | */ |
151 | - public function whereLike($field, $value, $glue = 'AND') |
|
151 | + public function whereLike( $field, $value, $glue = 'AND' ) |
|
152 | 152 | { |
153 | - return $this->where(array($field, $value, 'LIKE'), $glue); |
|
153 | + return $this->where( array( $field, $value, 'LIKE' ), $glue ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * @param $value |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function orWhereLike($field, $value) |
|
161 | + public function orWhereLike( $field, $value ) |
|
162 | 162 | { |
163 | - return $this->where(array($field, $value, 'LIKE'), 'OR'); |
|
163 | + return $this->where( array( $field, $value, 'LIKE' ), 'OR' ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * @param string $glue |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function whereNotLike($field, $value, $glue = 'AND') |
|
172 | + public function whereNotLike( $field, $value, $glue = 'AND' ) |
|
173 | 173 | { |
174 | - return $this->where(array($field, $value, 'NOT LIKE'), $glue); |
|
174 | + return $this->where( array( $field, $value, 'NOT LIKE' ), $glue ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * @param $value |
180 | 180 | * @return $this |
181 | 181 | */ |
182 | - public function orWhereNotLike($field, $value) |
|
182 | + public function orWhereNotLike( $field, $value ) |
|
183 | 183 | { |
184 | - return $this->where(array($field, $value, 'NOT LIKE'), 'OR'); |
|
184 | + return $this->where( array( $field, $value, 'NOT LIKE' ), 'OR' ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | * @param string $glue |
192 | 192 | * @return $this |
193 | 193 | */ |
194 | - public function whereBetween($field, $min, $max, $glue = 'AND') |
|
194 | + public function whereBetween( $field, $min, $max, $glue = 'AND' ) |
|
195 | 195 | { |
196 | - return $this->where(array($field, array($min, $max), 'BETWEEN'), $glue); |
|
196 | + return $this->where( array( $field, array( $min, $max ), 'BETWEEN' ), $glue ); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * @param $max |
203 | 203 | * @return $this |
204 | 204 | */ |
205 | - public function orWhereBetween($field, $min, $max) |
|
205 | + public function orWhereBetween( $field, $min, $max ) |
|
206 | 206 | { |
207 | - return $this->where(array($field, array($min, $max), 'BETWEEN'), 'OR'); |
|
207 | + return $this->where( array( $field, array( $min, $max ), 'BETWEEN' ), 'OR' ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | * @param string $glue |
215 | 215 | * @return $this |
216 | 216 | */ |
217 | - public function whereNotBetween($field, $min, $max, $glue = 'AND') |
|
217 | + public function whereNotBetween( $field, $min, $max, $glue = 'AND' ) |
|
218 | 218 | { |
219 | - return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), $glue); |
|
219 | + return $this->where( array( $field, array( $min, $max ), 'NOT BETWEEN' ), $glue ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | * @param $max |
226 | 226 | * @return $this |
227 | 227 | */ |
228 | - public function orWhereNotBetween($field, $min, $max) |
|
228 | + public function orWhereNotBetween( $field, $min, $max ) |
|
229 | 229 | { |
230 | - return $this->where(array($field, array($min, $max), 'NOT BETWEEN'), 'OR'); |
|
230 | + return $this->where( array( $field, array( $min, $max ), 'NOT BETWEEN' ), 'OR' ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param string $glue |
237 | 237 | * @return $this |
238 | 238 | */ |
239 | - public function whereIn($field, $value, $glue = 'AND') |
|
239 | + public function whereIn( $field, $value, $glue = 'AND' ) |
|
240 | 240 | { |
241 | - return $this->where(array($field, $value, 'IN'), $glue); |
|
241 | + return $this->where( array( $field, $value, 'IN' ), $glue ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * @param $value |
247 | 247 | * @return $this |
248 | 248 | */ |
249 | - public function orWhereIn($field, $value) |
|
249 | + public function orWhereIn( $field, $value ) |
|
250 | 250 | { |
251 | - return $this->where(array($field, $value, 'IN'), 'OR'); |
|
251 | + return $this->where( array( $field, $value, 'IN' ), 'OR' ); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param string $glue |
258 | 258 | * @return $this |
259 | 259 | */ |
260 | - public function whereNotIn($field, $value, $glue = 'AND') |
|
260 | + public function whereNotIn( $field, $value, $glue = 'AND' ) |
|
261 | 261 | { |
262 | - return $this->where(array($field, $value, 'NOT IN'), $glue); |
|
262 | + return $this->where( array( $field, $value, 'NOT IN' ), $glue ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * @param $value |
268 | 268 | * @return $this |
269 | 269 | */ |
270 | - public function orWhereNotIn($field, $value) |
|
270 | + public function orWhereNotIn( $field, $value ) |
|
271 | 271 | { |
272 | - return $this->where(array($field, $value, 'NOT IN'), 'OR'); |
|
272 | + return $this->where( array( $field, $value, 'NOT IN' ), 'OR' ); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | * @param string $glue |
279 | 279 | * @return $this |
280 | 280 | */ |
281 | - public function whereExpression($whereString, array $bindParams = [], $glue = 'AND') |
|
281 | + public function whereExpression( $whereString, array $bindParams = [ ], $glue = 'AND' ) |
|
282 | 282 | { |
283 | - $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
283 | + $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
|
284 | 284 | |
285 | - return $this->where($whereString, $glue); |
|
285 | + return $this->where( $whereString, $glue ); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | * @param array $bindParams |
291 | 291 | * @return $this |
292 | 292 | */ |
293 | - public function orWhereExpression($whereString, array $bindParams = []) |
|
293 | + public function orWhereExpression( $whereString, array $bindParams = [ ] ) |
|
294 | 294 | { |
295 | - $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
295 | + $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
|
296 | 296 | |
297 | - return $this->where($whereString, 'OR'); |
|
297 | + return $this->where( $whereString, 'OR' ); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function whereInvertResult() |
304 | 304 | { |
305 | - $this->queryStructure->setElement(QueryStructure::WHERE_INVERT, 1); |
|
305 | + $this->queryStructure->setElement( QueryStructure::WHERE_INVERT, 1 ); |
|
306 | 306 | |
307 | 307 | return $this; |
308 | 308 | } |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param string $glue |
312 | 312 | * @return $this |
313 | 313 | */ |
314 | - public function whereGroup($glue = 'AND') |
|
314 | + public function whereGroup( $glue = 'AND' ) |
|
315 | 315 | { |
316 | - $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group')); |
|
316 | + $this->queryStructure->setElement( QueryStructure::WHERE, array( 'glue' => $glue, 'body' => '(', 'type' => 'start_where_group' ) ); |
|
317 | 317 | |
318 | 318 | return $this; |
319 | 319 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public function orWhereGroup() |
325 | 325 | { |
326 | - return $this->whereGroup('OR'); |
|
326 | + return $this->whereGroup( 'OR' ); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function whereGroupEnd() |
333 | 333 | { |
334 | - $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => '', 'body' => ')', 'type' => 'end_where_group')); |
|
334 | + $this->queryStructure->setElement( QueryStructure::WHERE, array( 'glue' => '', 'body' => ')', 'type' => 'end_where_group' ) ); |
|
335 | 335 | |
336 | 336 | return $this; |
337 | 337 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function ignoreWhereTrigger() |
343 | 343 | { |
344 | - $this->queryStructure->setElement(QueryStructure::WHERE_TRIGGER, 0); |
|
344 | + $this->queryStructure->setElement( QueryStructure::WHERE_TRIGGER, 0 ); |
|
345 | 345 | |
346 | 346 | return $this; |
347 | 347 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | * @param string $glue |
353 | 353 | * @return $this |
354 | 354 | */ |
355 | - private function where($param, $glue = 'AND') |
|
355 | + private function where( $param, $glue = 'AND' ) |
|
356 | 356 | { |
357 | 357 | return $this->/** @scrutinizer ignore-call */ |
358 | - createCondition($param, $glue, QueryStructure::WHERE); |
|
358 | + createCondition( $param, $glue, QueryStructure::WHERE ); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | } |
362 | 362 | \ No newline at end of file |
@@ -15,48 +15,48 @@ |
||
15 | 15 | trait Limit |
16 | 16 | { |
17 | 17 | |
18 | - use Objects; |
|
18 | + use Objects; |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param int $limit |
|
23 | - * @param null $offset |
|
24 | - * @return $this |
|
25 | - * @throws QueryException |
|
26 | - */ |
|
27 | - public function limit($limit = 0, $offset = null) |
|
28 | - { |
|
29 | - $limit = trim($limit); |
|
21 | + /** |
|
22 | + * @param int $limit |
|
23 | + * @param null $offset |
|
24 | + * @return $this |
|
25 | + * @throws QueryException |
|
26 | + */ |
|
27 | + public function limit($limit = 0, $offset = null) |
|
28 | + { |
|
29 | + $limit = trim($limit); |
|
30 | 30 | |
31 | - if (!QueryHelper::isInteger($limit)) |
|
32 | - throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
31 | + if (!QueryHelper::isInteger($limit)) |
|
32 | + throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
33 | 33 | |
34 | - if ($limit == 0) |
|
35 | - throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
34 | + if ($limit == 0) |
|
35 | + throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
36 | 36 | |
37 | - if (is_null($offset)) { |
|
38 | - $this->queryStructure->setElement(QueryStructure::LIMIT, $limit); |
|
37 | + if (is_null($offset)) { |
|
38 | + $this->queryStructure->setElement(QueryStructure::LIMIT, $limit); |
|
39 | 39 | |
40 | - return $this; |
|
41 | - } |
|
40 | + return $this; |
|
41 | + } |
|
42 | 42 | |
43 | - $offset = trim($offset); |
|
43 | + $offset = trim($offset); |
|
44 | 44 | |
45 | - if (!QueryHelper::isInteger($offset)) |
|
46 | - throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
45 | + if (!QueryHelper::isInteger($offset)) |
|
46 | + throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
47 | 47 | |
48 | - $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit); |
|
48 | + $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit); |
|
49 | 49 | |
50 | - return $this; |
|
51 | - } |
|
50 | + return $this; |
|
51 | + } |
|
52 | 52 | |
53 | - private function getLimitSyntax() |
|
54 | - { |
|
55 | - if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) |
|
56 | - return ''; |
|
53 | + private function getLimitSyntax() |
|
54 | + { |
|
55 | + if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) |
|
56 | + return ''; |
|
57 | 57 | |
58 | - return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT); |
|
59 | - } |
|
58 | + return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
62 | 62 |
@@ -24,38 +24,38 @@ |
||
24 | 24 | * @return $this |
25 | 25 | * @throws QueryException |
26 | 26 | */ |
27 | - public function limit($limit = 0, $offset = null) |
|
27 | + public function limit( $limit = 0, $offset = null ) |
|
28 | 28 | { |
29 | - $limit = trim($limit); |
|
29 | + $limit = trim( $limit ); |
|
30 | 30 | |
31 | - if (!QueryHelper::isInteger($limit)) |
|
32 | - throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
31 | + if ( !QueryHelper::isInteger( $limit ) ) |
|
32 | + throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT ); |
|
33 | 33 | |
34 | - if ($limit == 0) |
|
35 | - throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
34 | + if ( $limit == 0 ) |
|
35 | + throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO ); |
|
36 | 36 | |
37 | - if (is_null($offset)) { |
|
38 | - $this->queryStructure->setElement(QueryStructure::LIMIT, $limit); |
|
37 | + if ( is_null( $offset ) ) { |
|
38 | + $this->queryStructure->setElement( QueryStructure::LIMIT, $limit ); |
|
39 | 39 | |
40 | 40 | return $this; |
41 | 41 | } |
42 | 42 | |
43 | - $offset = trim($offset); |
|
43 | + $offset = trim( $offset ); |
|
44 | 44 | |
45 | - if (!QueryHelper::isInteger($offset)) |
|
46 | - throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
45 | + if ( !QueryHelper::isInteger( $offset ) ) |
|
46 | + throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET ); |
|
47 | 47 | |
48 | - $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit); |
|
48 | + $this->queryStructure->setElement( QueryStructure::LIMIT, $offset . ',' . $limit ); |
|
49 | 49 | |
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | 53 | private function getLimitSyntax() |
54 | 54 | { |
55 | - if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) |
|
55 | + if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) ) |
|
56 | 56 | return ''; |
57 | 57 | |
58 | - return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT); |
|
58 | + return 'LIMIT ' . $this->queryStructure->getElement( QueryStructure::LIMIT ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | } |
@@ -28,11 +28,13 @@ discard block |
||
28 | 28 | { |
29 | 29 | $limit = trim($limit); |
30 | 30 | |
31 | - if (!QueryHelper::isInteger($limit)) |
|
32 | - throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
31 | + if (!QueryHelper::isInteger($limit)) { |
|
32 | + throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT); |
|
33 | + } |
|
33 | 34 | |
34 | - if ($limit == 0) |
|
35 | - throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
35 | + if ($limit == 0) { |
|
36 | + throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | if (is_null($offset)) { |
38 | 40 | $this->queryStructure->setElement(QueryStructure::LIMIT, $limit); |
@@ -42,8 +44,9 @@ discard block |
||
42 | 44 | |
43 | 45 | $offset = trim($offset); |
44 | 46 | |
45 | - if (!QueryHelper::isInteger($offset)) |
|
46 | - throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
47 | + if (!QueryHelper::isInteger($offset)) { |
|
48 | + throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET); |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit); |
49 | 52 | |
@@ -52,8 +55,9 @@ discard block |
||
52 | 55 | |
53 | 56 | private function getLimitSyntax() |
54 | 57 | { |
55 | - if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) |
|
56 | - return ''; |
|
58 | + if (!$this->queryStructure->getElement(QueryStructure::LIMIT)) { |
|
59 | + return ''; |
|
60 | + } |
|
57 | 61 | |
58 | 62 | return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT); |
59 | 63 | } |
@@ -12,18 +12,18 @@ |
||
12 | 12 | trait ColumnValidation |
13 | 13 | { |
14 | 14 | |
15 | - use Objects; |
|
15 | + use Objects; |
|
16 | 16 | |
17 | - protected function validateColumn($columnName, array $allowed) |
|
18 | - { |
|
19 | - if (is_integer($columnName)) |
|
20 | - return true; |
|
17 | + protected function validateColumn($columnName, array $allowed) |
|
18 | + { |
|
19 | + if (is_integer($columnName)) |
|
20 | + return true; |
|
21 | 21 | |
22 | - if (!count($allowed)) |
|
23 | - return true; |
|
22 | + if (!count($allowed)) |
|
23 | + return true; |
|
24 | 24 | |
25 | - return false; |
|
26 | - } |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -14,12 +14,12 @@ |
||
14 | 14 | |
15 | 15 | use Objects; |
16 | 16 | |
17 | - protected function validateColumn($columnName, array $allowed) |
|
17 | + protected function validateColumn( $columnName, array $allowed ) |
|
18 | 18 | { |
19 | - if (is_integer($columnName)) |
|
19 | + if ( is_integer( $columnName ) ) |
|
20 | 20 | return true; |
21 | 21 | |
22 | - if (!count($allowed)) |
|
22 | + if ( !count( $allowed ) ) |
|
23 | 23 | return true; |
24 | 24 | |
25 | 25 | return false; |
@@ -16,11 +16,13 @@ |
||
16 | 16 | |
17 | 17 | protected function validateColumn($columnName, array $allowed) |
18 | 18 | { |
19 | - if (is_integer($columnName)) |
|
20 | - return true; |
|
19 | + if (is_integer($columnName)) { |
|
20 | + return true; |
|
21 | + } |
|
21 | 22 | |
22 | - if (!count($allowed)) |
|
23 | - return true; |
|
23 | + if (!count($allowed)) { |
|
24 | + return true; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | return false; |
26 | 28 | } |
@@ -13,48 +13,48 @@ |
||
13 | 13 | trait Utilities |
14 | 14 | { |
15 | 15 | |
16 | - use Objects; |
|
16 | + use Objects; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @return $this |
|
21 | - */ |
|
22 | - public function explain() |
|
23 | - { |
|
24 | - $this->queryStructure->setElement(QueryStructure::EXPLAIN, 1); |
|
19 | + /** |
|
20 | + * @return $this |
|
21 | + */ |
|
22 | + public function explain() |
|
23 | + { |
|
24 | + $this->queryStructure->setElement(QueryStructure::EXPLAIN, 1); |
|
25 | 25 | |
26 | - return $this; |
|
27 | - } |
|
26 | + return $this; |
|
27 | + } |
|
28 | 28 | |
29 | - protected function getExplainSyntax() |
|
30 | - { |
|
31 | - if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
32 | - return 'EXPLAIN'; |
|
29 | + protected function getExplainSyntax() |
|
30 | + { |
|
31 | + if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
32 | + return 'EXPLAIN'; |
|
33 | 33 | |
34 | - return ''; |
|
35 | - } |
|
34 | + return ''; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $comment |
|
40 | - * @return $this |
|
41 | - */ |
|
42 | - public function withComment($comment = '') |
|
43 | - { |
|
44 | - $this->queryStructure->setElement(QueryStructure::QUERY_COMMENT, $comment); |
|
38 | + /** |
|
39 | + * @param string $comment |
|
40 | + * @return $this |
|
41 | + */ |
|
42 | + public function withComment($comment = '') |
|
43 | + { |
|
44 | + $this->queryStructure->setElement(QueryStructure::QUERY_COMMENT, $comment); |
|
45 | 45 | |
46 | - return $this; |
|
47 | - } |
|
46 | + return $this; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $identifier |
|
51 | - * @return $this |
|
52 | - */ |
|
53 | - public function withLogIdentifier($identifier = null) |
|
54 | - { |
|
55 | - $this->queryStructure->setElement(QueryStructure::QUERY_IDENTIFIER, $identifier); |
|
49 | + /** |
|
50 | + * @param string $identifier |
|
51 | + * @return $this |
|
52 | + */ |
|
53 | + public function withLogIdentifier($identifier = null) |
|
54 | + { |
|
55 | + $this->queryStructure->setElement(QueryStructure::QUERY_IDENTIFIER, $identifier); |
|
56 | 56 | |
57 | - return $this; |
|
58 | - } |
|
57 | + return $this; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function explain() |
23 | 23 | { |
24 | - $this->queryStructure->setElement(QueryStructure::EXPLAIN, 1); |
|
24 | + $this->queryStructure->setElement( QueryStructure::EXPLAIN, 1 ); |
|
25 | 25 | |
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function getExplainSyntax() |
30 | 30 | { |
31 | - if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
31 | + if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) ) |
|
32 | 32 | return 'EXPLAIN'; |
33 | 33 | |
34 | 34 | return ''; |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @param string $comment |
40 | 40 | * @return $this |
41 | 41 | */ |
42 | - public function withComment($comment = '') |
|
42 | + public function withComment( $comment = '' ) |
|
43 | 43 | { |
44 | - $this->queryStructure->setElement(QueryStructure::QUERY_COMMENT, $comment); |
|
44 | + $this->queryStructure->setElement( QueryStructure::QUERY_COMMENT, $comment ); |
|
45 | 45 | |
46 | 46 | return $this; |
47 | 47 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @param string $identifier |
51 | 51 | * @return $this |
52 | 52 | */ |
53 | - public function withLogIdentifier($identifier = null) |
|
53 | + public function withLogIdentifier( $identifier = null ) |
|
54 | 54 | { |
55 | - $this->queryStructure->setElement(QueryStructure::QUERY_IDENTIFIER, $identifier); |
|
55 | + $this->queryStructure->setElement( QueryStructure::QUERY_IDENTIFIER, $identifier ); |
|
56 | 56 | |
57 | 57 | return $this; |
58 | 58 | } |
@@ -28,8 +28,9 @@ |
||
28 | 28 | |
29 | 29 | protected function getExplainSyntax() |
30 | 30 | { |
31 | - if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) |
|
32 | - return 'EXPLAIN'; |
|
31 | + if ($this->queryStructure->getElement(QueryStructure::EXPLAIN)) { |
|
32 | + return 'EXPLAIN'; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | return ''; |
35 | 36 | } |