@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | * @param array $rowsForInsert |
| 26 | 26 | * @return $this |
| 27 | 27 | */ |
| 28 | - public function fromArray( $fieldsList, array $rowsForInsert ) |
|
| 28 | + public function fromArray($fieldsList, array $rowsForInsert) |
|
| 29 | 29 | { |
| 30 | - $this->setFieldsList( $fieldsList ); |
|
| 30 | + $this->setFieldsList($fieldsList); |
|
| 31 | 31 | |
| 32 | - foreach ( $rowsForInsert as $row ) |
|
| 33 | - $this->addSingleRow( $row ); |
|
| 32 | + foreach ($rowsForInsert as $row) |
|
| 33 | + $this->addSingleRow($row); |
|
| 34 | 34 | |
| 35 | 35 | return $this; |
| 36 | 36 | } |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * @param QuerySelect $query |
| 42 | 42 | * @return $this |
| 43 | 43 | */ |
| 44 | - public function fromQuerySelect( $fieldsList, QuerySelect $query ) |
|
| 44 | + public function fromQuerySelect($fieldsList, QuerySelect $query) |
|
| 45 | 45 | { |
| 46 | - $this->setFieldsList( $fieldsList ); |
|
| 46 | + $this->setFieldsList($fieldsList); |
|
| 47 | 47 | |
| 48 | - foreach ( $query->getBindParams() as $key => $value ) |
|
| 49 | - $this->queryStructure->setParams( $key, $value ); |
|
| 48 | + foreach ($query->getBindParams() as $key => $value) |
|
| 49 | + $this->queryStructure->setParams($key, $value); |
|
| 50 | 50 | |
| 51 | - $this->queryStructure->replaceElement( QueryStructure::SET_FIELDS, $query ); |
|
| 51 | + $this->queryStructure->replaceElement(QueryStructure::SET_FIELDS, $query); |
|
| 52 | 52 | |
| 53 | 53 | return $this; |
| 54 | 54 | } |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @param string|array $fieldList |
| 59 | 59 | */ |
| 60 | - private function setFieldsList( $fieldList ) |
|
| 60 | + private function setFieldsList($fieldList) |
|
| 61 | 61 | { |
| 62 | - if ( !is_array( $fieldList ) ) |
|
| 63 | - $fieldList = QueryHelper::explode( $fieldList ); |
|
| 62 | + if (!is_array($fieldList)) |
|
| 63 | + $fieldList = QueryHelper::explode($fieldList); |
|
| 64 | 64 | |
| 65 | - $this->queryStructure->replaceElement( QueryStructure::FIELDS, $fieldList ); |
|
| 65 | + $this->queryStructure->replaceElement(QueryStructure::FIELDS, $fieldList); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | * @return $this |
| 72 | 72 | * @throws QueryException |
| 73 | 73 | */ |
| 74 | - private function addSingleRow( array $rowValues ) |
|
| 74 | + private function addSingleRow(array $rowValues) |
|
| 75 | 75 | { |
| 76 | 76 | |
| 77 | - if ( $this->getNumberOfFields() !== count( $rowValues ) ) |
|
| 78 | - throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT ); |
|
| 77 | + if ($this->getNumberOfFields() !== count($rowValues)) |
|
| 78 | + throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT); |
|
| 79 | 79 | |
| 80 | 80 | $pdoRowValues = array(); |
| 81 | 81 | |
| 82 | - foreach ( $rowValues as $value ) |
|
| 83 | - $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
| 82 | + foreach ($rowValues as $value) |
|
| 83 | + $pdoRowValues[] = $this->queryStructure->bindParam('value', $value); |
|
| 84 | 84 | |
| 85 | - $pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )'; |
|
| 85 | + $pdoRowValuesString = '( ' . QueryHelper::implode($pdoRowValues, ', ') . ' )'; |
|
| 86 | 86 | |
| 87 | - $this->queryStructure->setElement( QueryStructure::SET_FIELDS, $pdoRowValuesString ); |
|
| 87 | + $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $pdoRowValuesString); |
|
| 88 | 88 | |
| 89 | 89 | return $this; |
| 90 | 90 | } |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | private function getInsertMultipleRowsSyntax() |
| 96 | 96 | { |
| 97 | - if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) |
|
| 97 | + if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class)) |
|
| 98 | 98 | return $this->getSyntaxWithSelect(); |
| 99 | 99 | |
| 100 | - $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )'; |
|
| 101 | - $values = QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), ', ' ); |
|
| 100 | + $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )'; |
|
| 101 | + $values = QueryHelper::implode($this->queryStructure->getElement(QueryStructure::SET_FIELDS), ', '); |
|
| 102 | 102 | |
| 103 | 103 | return $fields . ' VALUES ' . $values; |
| 104 | 104 | } |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | private function getSyntaxWithSelect() |
| 111 | 111 | { |
| 112 | - $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )'; |
|
| 112 | + $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )'; |
|
| 113 | 113 | |
| 114 | - return $fields . ' ' . $this->queryStructure->getElement( QueryStructure::SET_FIELDS )->getSyntax(); |
|
| 114 | + return $fields . ' ' . $this->queryStructure->getElement(QueryStructure::SET_FIELDS)->getSyntax(); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function getNumberOfFields() |
| 121 | 121 | { |
| 122 | - return count( $this->queryStructure->getElement( QueryStructure::FIELDS ) ); |
|
| 122 | + return count($this->queryStructure->getElement(QueryStructure::FIELDS)); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $this->setFieldsList( $fieldsList ); |
| 31 | 31 | |
| 32 | - foreach ( $rowsForInsert as $row ) |
|
| 33 | - $this->addSingleRow( $row ); |
|
| 32 | + foreach ( $rowsForInsert as $row ) { |
|
| 33 | + $this->addSingleRow( $row ); |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | 36 | return $this; |
| 36 | 37 | } |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | { |
| 46 | 47 | $this->setFieldsList( $fieldsList ); |
| 47 | 48 | |
| 48 | - foreach ( $query->getBindParams() as $key => $value ) |
|
| 49 | - $this->queryStructure->setParams( $key, $value ); |
|
| 49 | + foreach ( $query->getBindParams() as $key => $value ) { |
|
| 50 | + $this->queryStructure->setParams( $key, $value ); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $this->queryStructure->replaceElement( QueryStructure::SET_FIELDS, $query ); |
| 52 | 54 | |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | */ |
| 60 | 62 | private function setFieldsList( $fieldList ) |
| 61 | 63 | { |
| 62 | - if ( !is_array( $fieldList ) ) |
|
| 63 | - $fieldList = QueryHelper::explode( $fieldList ); |
|
| 64 | + if ( !is_array( $fieldList ) ) { |
|
| 65 | + $fieldList = QueryHelper::explode( $fieldList ); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | $this->queryStructure->replaceElement( QueryStructure::FIELDS, $fieldList ); |
| 66 | 69 | |
@@ -74,13 +77,15 @@ discard block |
||
| 74 | 77 | private function addSingleRow( array $rowValues ) |
| 75 | 78 | { |
| 76 | 79 | |
| 77 | - if ( $this->getNumberOfFields() !== count( $rowValues ) ) |
|
| 78 | - throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT ); |
|
| 80 | + if ( $this->getNumberOfFields() !== count( $rowValues ) ) { |
|
| 81 | + throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT ); |
|
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | $pdoRowValues = array(); |
| 81 | 85 | |
| 82 | - foreach ( $rowValues as $value ) |
|
| 83 | - $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
| 86 | + foreach ( $rowValues as $value ) { |
|
| 87 | + $pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value ); |
|
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | $pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )'; |
| 86 | 91 | |
@@ -94,8 +99,9 @@ discard block |
||
| 94 | 99 | */ |
| 95 | 100 | private function getInsertMultipleRowsSyntax() |
| 96 | 101 | { |
| 97 | - if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) |
|
| 98 | - return $this->getSyntaxWithSelect(); |
|
| 102 | + if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) { |
|
| 103 | + return $this->getSyntaxWithSelect(); |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )'; |
| 101 | 107 | $values = QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), ', ' ); |
@@ -26,22 +26,22 @@ discard block |
||
| 26 | 26 | * @param $clauseType |
| 27 | 27 | * @return $this |
| 28 | 28 | */ |
| 29 | - protected function createCondition( $param, $glue = 'AND', $clauseType ) |
|
| 29 | + protected function createCondition($param, $glue = 'AND', $clauseType) |
|
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - if ( !is_array( $param ) ) { |
|
| 33 | - $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => trim( $param ), 'type' => 'cond' ) ); |
|
| 32 | + if (!is_array($param)) { |
|
| 33 | + $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => trim($param), 'type' => 'cond')); |
|
| 34 | 34 | |
| 35 | 35 | return $this; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $param = $this->validateWhereParam( $param ); |
|
| 38 | + $param = $this->validateWhereParam($param); |
|
| 39 | 39 | |
| 40 | 40 | $field = $param[0]; |
| 41 | 41 | $value = $param[1]; |
| 42 | 42 | $operator = $param[2]; |
| 43 | 43 | |
| 44 | - switch ( $operator ) { |
|
| 44 | + switch ($operator) { |
|
| 45 | 45 | case 'BETWEEN': |
| 46 | 46 | case 'NOT BETWEEN': |
| 47 | 47 | case '!BETWEEN': |
@@ -50,27 +50,27 @@ discard block |
||
| 50 | 50 | $body = [ |
| 51 | 51 | $field, |
| 52 | 52 | $operator, |
| 53 | - $this->queryStructure->bindParam( 'min', $min ), |
|
| 53 | + $this->queryStructure->bindParam('min', $min), |
|
| 54 | 54 | 'AND', |
| 55 | - $this->queryStructure->bindParam( 'max', $max ) |
|
| 55 | + $this->queryStructure->bindParam('max', $max) |
|
| 56 | 56 | ]; |
| 57 | - $body = implode( ' ', $body ); |
|
| 58 | - $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) ); |
|
| 57 | + $body = implode(' ', $body); |
|
| 58 | + $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond')); |
|
| 59 | 59 | break; |
| 60 | 60 | |
| 61 | 61 | case 'IN': |
| 62 | 62 | case 'NOT IN': |
| 63 | 63 | case '!IN': |
| 64 | - if ( is_a( $value, QuerySelect::class ) ) |
|
| 65 | - return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); |
|
| 66 | - elseif ( is_array( $value ) ) |
|
| 67 | - return $this->inArray( $field, $value, $operator, $glue, $clauseType ); |
|
| 64 | + if (is_a($value, QuerySelect::class)) |
|
| 65 | + return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); |
|
| 66 | + elseif (is_array($value)) |
|
| 67 | + return $this->inArray($field, $value, $operator, $glue, $clauseType); |
|
| 68 | 68 | break; |
| 69 | 69 | |
| 70 | 70 | default: |
| 71 | - $valuePdoString = $this->queryStructure->bindParam( $field, $value ); |
|
| 71 | + $valuePdoString = $this->queryStructure->bindParam($field, $value); |
|
| 72 | 72 | $body = $field . ' ' . $operator . ' ' . $valuePdoString; |
| 73 | - $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) ); |
|
| 73 | + $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond')); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | * @param $clauseType |
| 88 | 88 | * @return $this |
| 89 | 89 | */ |
| 90 | - private function inSelectObject( $field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType ) |
|
| 90 | + private function inSelectObject($field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType) |
|
| 91 | 91 | { |
| 92 | 92 | $subquerySelectParams = $subquerySelect->getBindParams(); |
| 93 | - foreach ( $subquerySelectParams as $key => $value ) { |
|
| 94 | - $this->queryStructure->setParams( $key, $value ); |
|
| 93 | + foreach ($subquerySelectParams as $key => $value) { |
|
| 94 | + $this->queryStructure->setParams($key, $value); |
|
| 95 | 95 | } |
| 96 | 96 | $body = [ |
| 97 | 97 | $field, |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | $subquerySelect->getSyntax(), |
| 101 | 101 | ' )' |
| 102 | 102 | ]; |
| 103 | - $body = implode( ' ', $body ); |
|
| 104 | - $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) ); |
|
| 103 | + $body = implode(' ', $body); |
|
| 104 | + $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond')); |
|
| 105 | 105 | |
| 106 | 106 | return $this; |
| 107 | 107 | } |
@@ -114,20 +114,20 @@ discard block |
||
| 114 | 114 | * @param $clauseType |
| 115 | 115 | * @return $this |
| 116 | 116 | */ |
| 117 | - private function inArray( $field, array $value, $operator, $glue, $clauseType ) |
|
| 117 | + private function inArray($field, array $value, $operator, $glue, $clauseType) |
|
| 118 | 118 | { |
| 119 | 119 | $pdoArray = array(); |
| 120 | - foreach ( $value as $item ) { |
|
| 121 | - $pdoArray[] = $this->queryStructure->bindParam( 'a', $item ); |
|
| 120 | + foreach ($value as $item) { |
|
| 121 | + $pdoArray[] = $this->queryStructure->bindParam('a', $item); |
|
| 122 | 122 | } |
| 123 | 123 | $body = [ |
| 124 | 124 | $field, |
| 125 | 125 | $operator, |
| 126 | - '( ' . implode( ', ', $pdoArray ) . ' )' |
|
| 126 | + '( ' . implode(', ', $pdoArray) . ' )' |
|
| 127 | 127 | ]; |
| 128 | - $body = implode( ' ', $body ); |
|
| 129 | - $body = QueryHelper::clearMultipleSpaces( $body ); |
|
| 130 | - $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) ); |
|
| 128 | + $body = implode(' ', $body); |
|
| 129 | + $body = QueryHelper::clearMultipleSpaces($body); |
|
| 130 | + $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond')); |
|
| 131 | 131 | |
| 132 | 132 | return $this; |
| 133 | 133 | } |
@@ -146,36 +146,36 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | private function getHavingSyntax() |
| 148 | 148 | { |
| 149 | - return $this->getWhereAndHavingSyntax( QueryStructure::HAVING); |
|
| 149 | + return $this->getWhereAndHavingSyntax(QueryStructure::HAVING); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * @param $clauseType |
| 154 | 154 | * @return bool|mixed|string |
| 155 | 155 | */ |
| 156 | - private function getWhereAndHavingSyntax( $clauseType ) |
|
| 156 | + private function getWhereAndHavingSyntax($clauseType) |
|
| 157 | 157 | { |
| 158 | - if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) |
|
| 158 | + if (count($this->queryStructure->getElement($clauseType)) == 0) |
|
| 159 | 159 | return ''; |
| 160 | 160 | |
| 161 | 161 | $where = ''; |
| 162 | 162 | $last_type = 'where_start'; |
| 163 | - foreach ( $this->queryStructure->getElement( $clauseType ) as $where_cond ) { |
|
| 163 | + foreach ($this->queryStructure->getElement($clauseType) as $where_cond) { |
|
| 164 | 164 | $glue = $where_cond['glue']; |
| 165 | - if ( $last_type == 'where_start' || $last_type == 'start_where_group' ) { |
|
| 165 | + if ($last_type == 'where_start' || $last_type == 'start_where_group') { |
|
| 166 | 166 | $glue = ''; |
| 167 | 167 | } |
| 168 | 168 | $where .= ' ' . $glue . ' ' . $where_cond['body']; |
| 169 | 169 | $last_type = $where_cond['type']; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ( $this->queryStructure->getElement( $clauseType.'_invert' ) ) { |
|
| 172 | + if ($this->queryStructure->getElement($clauseType . '_invert')) { |
|
| 173 | 173 | $where = ' NOT ( ' . $where . ' ) '; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $where = 'WHERE ' . $where; |
| 177 | 177 | |
| 178 | - return QueryHelper::clearMultipleSpaces( $where ); |
|
| 178 | + return QueryHelper::clearMultipleSpaces($where); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -183,16 +183,16 @@ discard block |
||
| 183 | 183 | * @return array |
| 184 | 184 | * @throws QueryException |
| 185 | 185 | */ |
| 186 | - private function validateWhereParam( $param ) |
|
| 186 | + private function validateWhereParam($param) |
|
| 187 | 187 | { |
| 188 | - if ( count( $param ) < 2 ) |
|
| 189 | - throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
| 188 | + if (count($param) < 2) |
|
| 189 | + throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY); |
|
| 190 | 190 | |
| 191 | - if ( count( $param ) == 2 ) |
|
| 191 | + if (count($param) == 2) |
|
| 192 | 192 | $param[] = '='; |
| 193 | 193 | |
| 194 | - $param[2] = trim( strtoupper( $param[2] ) ); |
|
| 195 | - $param[2] = QueryHelper::clearMultipleSpaces( $param[2] ); |
|
| 194 | + $param[2] = trim(strtoupper($param[2])); |
|
| 195 | + $param[2] = QueryHelper::clearMultipleSpaces($param[2]); |
|
| 196 | 196 | |
| 197 | 197 | return $param; |
| 198 | 198 | } |
@@ -61,10 +61,11 @@ discard block |
||
| 61 | 61 | case 'IN': |
| 62 | 62 | case 'NOT IN': |
| 63 | 63 | case '!IN': |
| 64 | - if ( is_a( $value, QuerySelect::class ) ) |
|
| 65 | - return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); |
|
| 66 | - elseif ( is_array( $value ) ) |
|
| 67 | - return $this->inArray( $field, $value, $operator, $glue, $clauseType ); |
|
| 64 | + if ( is_a( $value, QuerySelect::class ) ) { |
|
| 65 | + return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); |
|
| 66 | + } elseif ( is_array( $value ) ) { |
|
| 67 | + return $this->inArray( $field, $value, $operator, $glue, $clauseType ); |
|
| 68 | + } |
|
| 68 | 69 | break; |
| 69 | 70 | |
| 70 | 71 | default: |
@@ -155,8 +156,9 @@ discard block |
||
| 155 | 156 | */ |
| 156 | 157 | private function getWhereAndHavingSyntax( $clauseType ) |
| 157 | 158 | { |
| 158 | - if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) |
|
| 159 | - return ''; |
|
| 159 | + if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) { |
|
| 160 | + return ''; |
|
| 161 | + } |
|
| 160 | 162 | |
| 161 | 163 | $where = ''; |
| 162 | 164 | $last_type = 'where_start'; |
@@ -185,11 +187,13 @@ discard block |
||
| 185 | 187 | */ |
| 186 | 188 | private function validateWhereParam( $param ) |
| 187 | 189 | { |
| 188 | - if ( count( $param ) < 2 ) |
|
| 189 | - throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
| 190 | + if ( count( $param ) < 2 ) { |
|
| 191 | + throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
|
| 192 | + } |
|
| 190 | 193 | |
| 191 | - if ( count( $param ) == 2 ) |
|
| 192 | - $param[] = '='; |
|
| 194 | + if ( count( $param ) == 2 ) { |
|
| 195 | + $param[] = '='; |
|
| 196 | + } |
|
| 193 | 197 | |
| 194 | 198 | $param[2] = trim( strtoupper( $param[2] ) ); |
| 195 | 199 | $param[2] = QueryHelper::clearMultipleSpaces( $param[2] ); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function all() |
| 25 | 25 | { |
| 26 | - $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); |
|
| 26 | + $this->queryStructure->setElement(QueryStructure::DISTINCT, 0); |
|
| 27 | 27 | |
| 28 | 28 | return $this; |
| 29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function distinct() |
| 35 | 35 | { |
| 36 | - $this->queryStructure->setElement( QueryStructure::DISTINCT, 1 ); |
|
| 36 | + $this->queryStructure->setElement(QueryStructure::DISTINCT, 1); |
|
| 37 | 37 | |
| 38 | 38 | return $this; |
| 39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function distinctRow() |
| 45 | 45 | { |
| 46 | - $this->queryStructure->setElement( QueryStructure::DISTINCT, 2 ); |
|
| 46 | + $this->queryStructure->setElement(QueryStructure::DISTINCT, 2); |
|
| 47 | 47 | |
| 48 | 48 | return $this; |
| 49 | 49 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | private function getDistinctSyntax() |
| 57 | 57 | { |
| 58 | - $useDistinct = $this->queryStructure->getElement( QueryStructure::DISTINCT ); |
|
| 58 | + $useDistinct = $this->queryStructure->getElement(QueryStructure::DISTINCT); |
|
| 59 | 59 | |
| 60 | - switch ( $useDistinct ) { |
|
| 60 | + switch ($useDistinct) { |
|
| 61 | 61 | case 0: |
| 62 | 62 | return ''; |
| 63 | 63 | break; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return 'DISTINCTROW'; |
| 69 | 69 | break; |
| 70 | 70 | default: |
| 71 | - throw new QueryException( 'Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT ); |
|
| 71 | + throw new QueryException('Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | } |
@@ -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 | } |
@@ -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,10 +278,10 @@ 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 ); |
|
| 284 | - return $this->where( $whereString, $glue ); |
|
| 283 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
| 284 | + return $this->where($whereString, $glue); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | * @param array $bindParams |
| 290 | 290 | * @return $this |
| 291 | 291 | */ |
| 292 | - public function orWhereExpression( $whereString, array $bindParams = [] ) |
|
| 292 | + public function orWhereExpression($whereString, array $bindParams = []) |
|
| 293 | 293 | { |
| 294 | - $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
|
| 295 | - return $this->where( $whereString, 'OR' ); |
|
| 294 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
| 295 | + return $this->where($whereString, 'OR'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function whereInvertResult() |
| 302 | 302 | { |
| 303 | - $this->queryStructure->setElement( QueryStructure::WHERE_INVERT, 1 ); |
|
| 303 | + $this->queryStructure->setElement(QueryStructure::WHERE_INVERT, 1); |
|
| 304 | 304 | |
| 305 | 305 | return $this; |
| 306 | 306 | } |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * @param string $glue |
| 310 | 310 | * @return $this |
| 311 | 311 | */ |
| 312 | - public function whereGroup( $glue = 'AND' ) |
|
| 312 | + public function whereGroup($glue = 'AND') |
|
| 313 | 313 | { |
| 314 | - $this->queryStructure->setElement( QueryStructure::WHERE, array( 'glue' => $glue, 'body' => '(', 'type' => 'start_where_group' ) ); |
|
| 314 | + $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group')); |
|
| 315 | 315 | |
| 316 | 316 | return $this; |
| 317 | 317 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function orWhereGroup() |
| 323 | 323 | { |
| 324 | - return $this->whereGroup( 'OR' ); |
|
| 324 | + return $this->whereGroup('OR'); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function whereGroupEnd() |
| 331 | 331 | { |
| 332 | - $this->queryStructure->setElement( QueryStructure::WHERE, array( 'glue' => '', 'body' => ')', 'type' => 'end_where_group' ) ); |
|
| 332 | + $this->queryStructure->setElement(QueryStructure::WHERE, array('glue' => '', 'body' => ')', 'type' => 'end_where_group')); |
|
| 333 | 333 | |
| 334 | 334 | return $this; |
| 335 | 335 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function ignoreWhereTrigger() |
| 341 | 341 | { |
| 342 | - $this->queryStructure->setElement( QueryStructure::WHERE_TRIGGER, 0 ); |
|
| 342 | + $this->queryStructure->setElement(QueryStructure::WHERE_TRIGGER, 0); |
|
| 343 | 343 | |
| 344 | 344 | return $this; |
| 345 | 345 | } |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | * @param string $glue |
| 351 | 351 | * @return $this |
| 352 | 352 | */ |
| 353 | - private function where( $param, $glue = 'AND' ) |
|
| 353 | + private function where($param, $glue = 'AND') |
|
| 354 | 354 | { |
| 355 | - return $this->createCondition($param, $glue, QueryStructure::WHERE ); |
|
| 355 | + return $this->createCondition($param, $glue, QueryStructure::WHERE); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function ignore() |
| 23 | 23 | { |
| 24 | - $this->queryStructure->setElement( QueryStructure::IGNORE, 1 ); |
|
| 24 | + $this->queryStructure->setElement(QueryStructure::IGNORE, 1); |
|
| 25 | 25 | |
| 26 | 26 | return $this; |
| 27 | 27 | } |
@@ -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 ) ) |
|
| 31 | + if (!$this->validateColumn($column, $allowedColumns)) |
|
| 32 | 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 ) ) |
|
| 50 | + if (!$this->validateColumn($column, $allowedColumns)) |
|
| 51 | 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 | } |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | trait TableValidation |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - private function validateTable( $table ) |
|
| 20 | + private function validateTable($table) |
|
| 21 | 21 | { |
| 22 | - switch ( gettype( $table ) ) { |
|
| 22 | + switch (gettype($table)) { |
|
| 23 | 23 | |
| 24 | 24 | case QueryStructure::ELEMENT_TYPE_STRING: |
| 25 | - $table = $this->validateTableName( $table ); |
|
| 25 | + $table = $this->validateTableName($table); |
|
| 26 | 26 | break; |
| 27 | 27 | case QueryStructure::ELEMENT_TYPE_OBJECT: |
| 28 | - $table = $this->validateTableSubQuery( $table ); |
|
| 28 | + $table = $this->validateTableSubQuery($table); |
|
| 29 | 29 | break; |
| 30 | 30 | default: |
| 31 | - throw new QueryException( 'Invalid table type parameter: ' . gettype( $table ), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 31 | + throw new QueryException('Invalid table type parameter: ' . gettype($table), QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,26 +40,26 @@ discard block |
||
| 40 | 40 | * @return mixed|string |
| 41 | 41 | * @throws QueryException |
| 42 | 42 | */ |
| 43 | - private function validateTableName( $table ) |
|
| 43 | + private function validateTableName($table) |
|
| 44 | 44 | { |
| 45 | - $table = trim( $table ); |
|
| 45 | + $table = trim($table); |
|
| 46 | 46 | |
| 47 | - if ( '' === $table ) |
|
| 48 | - throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 47 | + if ('' === $table) |
|
| 48 | + throw new QueryException('Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
| 49 | 49 | |
| 50 | - if ( DbConfig::getInstance()->useTablePrefix() ) |
|
| 51 | - $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
| 50 | + if (DbConfig::getInstance()->useTablePrefix()) |
|
| 51 | + $table = str_ireplace('::', DbConfig::getInstance()->getTablePrefix(), $table); |
|
| 52 | 52 | |
| 53 | 53 | return $table; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - private function validateTableSubQuery( $table ) |
|
| 56 | + private function validateTableSubQuery($table) |
|
| 57 | 57 | { |
| 58 | - if ( $this->statement !== self::QUERY_STATEMENT_SELECT ) |
|
| 59 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 58 | + if ($this->statement !== self::QUERY_STATEMENT_SELECT) |
|
| 59 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
| 60 | 60 | |
| 61 | - if ( !is_a( $table, QuerySelect::class ) ) |
|
| 62 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 61 | + if (!is_a($table, QuerySelect::class)) |
|
| 62 | + throw new QueryException('Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT); |
|
| 63 | 63 | |
| 64 | 64 | return $table; |
| 65 | 65 | } |
@@ -44,22 +44,26 @@ |
||
| 44 | 44 | { |
| 45 | 45 | $table = trim( $table ); |
| 46 | 46 | |
| 47 | - if ( '' === $table ) |
|
| 48 | - throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 47 | + if ( '' === $table ) { |
|
| 48 | + throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | - if ( DbConfig::getInstance()->useTablePrefix() ) |
|
| 51 | - $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
| 51 | + if ( DbConfig::getInstance()->useTablePrefix() ) { |
|
| 52 | + $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | return $table; |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | private function validateTableSubQuery( $table ) |
| 57 | 59 | { |
| 58 | - if ( $this->statement !== self::QUERY_STATEMENT_SELECT ) |
|
| 59 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 60 | + if ( $this->statement !== self::QUERY_STATEMENT_SELECT ) { |
|
| 61 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 62 | + } |
|
| 60 | 63 | |
| 61 | - if ( !is_a( $table, QuerySelect::class ) ) |
|
| 62 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 64 | + if ( !is_a( $table, QuerySelect::class ) ) { |
|
| 65 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | return $table; |
| 65 | 69 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | * @param $glue |
| 23 | 23 | * @return $this |
| 24 | 24 | */ |
| 25 | - public function havingEqual( $field, $value, $glue = 'AND' ) |
|
| 25 | + public function havingEqual($field, $value, $glue = 'AND') |
|
| 26 | 26 | { |
| 27 | - return $this->having( array( $field, $value, '=' ), $glue ); |
|
| 27 | + return $this->having(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 orHavingEqual( $field, $value ) |
|
| 35 | + public function orHavingEqual($field, $value) |
|
| 36 | 36 | { |
| 37 | - return $this->having( array( $field, $value, '=' ), 'OR' ); |
|
| 37 | + return $this->having(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 havingNotEqual( $field, $value, $glue = 'AND' ) |
|
| 46 | + public function havingNotEqual($field, $value, $glue = 'AND') |
|
| 47 | 47 | { |
| 48 | - return $this->having( array( $field, $value, '<>' ), $glue ); |
|
| 48 | + return $this->having(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 orHavingNotEqual( $field, $value ) |
|
| 56 | + public function orHavingNotEqual($field, $value) |
|
| 57 | 57 | { |
| 58 | - return $this->having( array( $field, $value, '<>' ), 'OR' ); |
|
| 58 | + return $this->having(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 havingLessThan( $field, $value, $glue = 'AND' ) |
|
| 67 | + public function havingLessThan($field, $value, $glue = 'AND') |
|
| 68 | 68 | { |
| 69 | - return $this->having( array( $field, $value, '<' ), $glue ); |
|
| 69 | + return $this->having(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 orHavingLessThan( $field, $value ) |
|
| 77 | + public function orHavingLessThan($field, $value) |
|
| 78 | 78 | { |
| 79 | - return $this->having( array( $field, $value, '<' ), 'OR' ); |
|
| 79 | + return $this->having(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 havingLessThanOrEqual( $field, $value, $glue = 'AND' ) |
|
| 88 | + public function havingLessThanOrEqual($field, $value, $glue = 'AND') |
|
| 89 | 89 | { |
| 90 | - return $this->having( array( $field, $value, '<=' ), $glue ); |
|
| 90 | + return $this->having(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 orHavingLessThanOrEqual( $field, $value ) |
|
| 98 | + public function orHavingLessThanOrEqual($field, $value) |
|
| 99 | 99 | { |
| 100 | - return $this->having( array( $field, $value, '<=' ), 'OR' ); |
|
| 100 | + return $this->having(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 havingGreaterThan( $field, $value, $glue = 'AND' ) |
|
| 109 | + public function havingGreaterThan($field, $value, $glue = 'AND') |
|
| 110 | 110 | { |
| 111 | - return $this->having( array( $field, $value, '>' ), $glue ); |
|
| 111 | + return $this->having(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 orHavingGreaterThan( $field, $value ) |
|
| 119 | + public function orHavingGreaterThan($field, $value) |
|
| 120 | 120 | { |
| 121 | - return $this->having( array( $field, $value, '>' ), 'OR' ); |
|
| 121 | + return $this->having(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 havingGreaterThanOrEqual( $field, $value, $glue = 'AND' ) |
|
| 130 | + public function havingGreaterThanOrEqual($field, $value, $glue = 'AND') |
|
| 131 | 131 | { |
| 132 | - return $this->having( array( $field, $value, '>=' ), $glue ); |
|
| 132 | + return $this->having(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 orHavingGreaterThanOrEqual( $field, $value ) |
|
| 140 | + public function orHavingGreaterThanOrEqual($field, $value) |
|
| 141 | 141 | { |
| 142 | - return $this->having( array( $field, $value, '>=' ), 'OR' ); |
|
| 142 | + return $this->having(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 havingLike( $field, $value, $glue = 'AND' ) |
|
| 151 | + public function havingLike($field, $value, $glue = 'AND') |
|
| 152 | 152 | { |
| 153 | - return $this->having( array( $field, $value, 'LIKE' ), $glue ); |
|
| 153 | + return $this->having(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 orHavingLike( $field, $value ) |
|
| 161 | + public function orHavingLike($field, $value) |
|
| 162 | 162 | { |
| 163 | - return $this->having( array( $field, $value, 'LIKE' ), 'OR' ); |
|
| 163 | + return $this->having(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 havingNotLike( $field, $value, $glue = 'AND' ) |
|
| 172 | + public function havingNotLike($field, $value, $glue = 'AND') |
|
| 173 | 173 | { |
| 174 | - return $this->having( array( $field, $value, 'NOT LIKE' ), $glue ); |
|
| 174 | + return $this->having(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 orHavingNotLike( $field, $value ) |
|
| 182 | + public function orHavingNotLike($field, $value) |
|
| 183 | 183 | { |
| 184 | - return $this->having( array( $field, $value, 'NOT LIKE' ), 'OR' ); |
|
| 184 | + return $this->having(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 havingBetween( $field, $min, $max, $glue = 'AND' ) |
|
| 194 | + public function havingBetween($field, $min, $max, $glue = 'AND') |
|
| 195 | 195 | { |
| 196 | - return $this->having( array( $field, array( $min, $max ), 'BETWEEN' ), $glue ); |
|
| 196 | + return $this->having(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 orHavingBetween( $field, $min, $max ) |
|
| 205 | + public function orHavingBetween($field, $min, $max) |
|
| 206 | 206 | { |
| 207 | - return $this->having( array( $field, array( $min, $max ), 'BETWEEN' ), 'OR' ); |
|
| 207 | + return $this->having(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 havingNotBetween( $field, $min, $max, $glue = 'AND' ) |
|
| 217 | + public function havingNotBetween($field, $min, $max, $glue = 'AND') |
|
| 218 | 218 | { |
| 219 | - return $this->having( array( $field, array( $min, $max ), 'NOT BETWEEN' ), $glue ); |
|
| 219 | + return $this->having(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 orHavingNotBetween( $field, $min, $max ) |
|
| 228 | + public function orHavingNotBetween($field, $min, $max) |
|
| 229 | 229 | { |
| 230 | - return $this->having( array( $field, array( $min, $max ), 'NOT BETWEEN' ), 'OR' ); |
|
| 230 | + return $this->having(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 havingIn( $field, $value, $glue = 'AND' ) |
|
| 239 | + public function havingIn($field, $value, $glue = 'AND') |
|
| 240 | 240 | { |
| 241 | - return $this->having( array( $field, $value, 'IN' ), $glue ); |
|
| 241 | + return $this->having(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 orHavingIn( $field, $value ) |
|
| 249 | + public function orHavingIn($field, $value) |
|
| 250 | 250 | { |
| 251 | - return $this->having( array( $field, $value, 'IN' ), 'OR' ); |
|
| 251 | + return $this->having(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 havingNotIn( $field, $value, $glue = 'AND' ) |
|
| 260 | + public function havingNotIn($field, $value, $glue = 'AND') |
|
| 261 | 261 | { |
| 262 | - return $this->having( array( $field, $value, 'NOT IN' ), $glue ); |
|
| 262 | + return $this->having(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 orHavingNotIn( $field, $value ) |
|
| 270 | + public function orHavingNotIn($field, $value) |
|
| 271 | 271 | { |
| 272 | - return $this->having( array( $field, $value, 'NOT IN' ), 'OR' ); |
|
| 272 | + return $this->having(array($field, $value, 'NOT IN'), 'OR'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | * @param string $glue |
| 279 | 279 | * @return $this |
| 280 | 280 | */ |
| 281 | - public function havingExpression( $whereString, array $bindParams = [], $glue = 'AND' ) |
|
| 281 | + public function havingExpression($whereString, array $bindParams = [], $glue = 'AND') |
|
| 282 | 282 | { |
| 283 | - $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
|
| 284 | - return $this->having( $whereString, $glue ); |
|
| 283 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
| 284 | + return $this->having($whereString, $glue); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | * @param array $bindParams |
| 290 | 290 | * @return $this |
| 291 | 291 | */ |
| 292 | - public function orHavingExpression( $whereString, array $bindParams = [] ) |
|
| 292 | + public function orHavingExpression($whereString, array $bindParams = []) |
|
| 293 | 293 | { |
| 294 | - $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
|
| 295 | - return $this->having( $whereString, 'OR' ); |
|
| 294 | + $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams); |
|
| 295 | + return $this->having($whereString, 'OR'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function havingInvertResult() |
| 302 | 302 | { |
| 303 | - $this->queryStructure->setElement( QueryStructure::HAVING_INVERT, 1 ); |
|
| 303 | + $this->queryStructure->setElement(QueryStructure::HAVING_INVERT, 1); |
|
| 304 | 304 | |
| 305 | 305 | return $this; |
| 306 | 306 | } |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * @param string $glue |
| 310 | 310 | * @return $this |
| 311 | 311 | */ |
| 312 | - public function havingGroup( $glue = 'AND' ) |
|
| 312 | + public function havingGroup($glue = 'AND') |
|
| 313 | 313 | { |
| 314 | - $this->queryStructure->setElement( QueryStructure::HAVING, array( 'glue' => $glue, 'body' => '(', 'type' => 'start_where_group' ) ); |
|
| 314 | + $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group')); |
|
| 315 | 315 | |
| 316 | 316 | return $this; |
| 317 | 317 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function orHavingGroup() |
| 323 | 323 | { |
| 324 | - return $this->havingGroup( 'OR' ); |
|
| 324 | + return $this->havingGroup('OR'); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function havingGroupEnd() |
| 331 | 331 | { |
| 332 | - $this->queryStructure->setElement( QueryStructure::HAVING, array( 'glue' => '', 'body' => ')', 'type' => 'end_where_group' ) ); |
|
| 332 | + $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => '', 'body' => ')', 'type' => 'end_where_group')); |
|
| 333 | 333 | |
| 334 | 334 | return $this; |
| 335 | 335 | } |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | * @param string $glue |
| 340 | 340 | * @return $this |
| 341 | 341 | */ |
| 342 | - private function having( $param, $glue = 'AND' ) |
|
| 342 | + private function having($param, $glue = 'AND') |
|
| 343 | 343 | { |
| 344 | - return $this->createCondition($param, $glue, QueryStructure::HAVING ); |
|
| 344 | + return $this->createCondition($param, $glue, QueryStructure::HAVING); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | } |
| 348 | 348 | \ No newline at end of file |