@@ -44,8 +44,8 @@ |
||
| 44 | 44 | 'db_log' => [ |
| 45 | 45 | 'enable_log_errors' => false, |
| 46 | 46 | 'enable_log_query_duration' => false, |
| 47 | - 'log_path_errors' => $_SERVER['DOCUMENT_ROOT'] . '/tmp/db_errors/', |
|
| 48 | - 'log_path_query_duration' => $_SERVER['DOCUMENT_ROOT'] . '/tmp/db_query_duration/', |
|
| 47 | + 'log_path_errors' => $_SERVER[ 'DOCUMENT_ROOT' ] . '/tmp/db_errors/', |
|
| 48 | + 'log_path_query_duration' => $_SERVER[ 'DOCUMENT_ROOT' ] . '/tmp/db_query_duration/', |
|
| 49 | 49 | ], |
| 50 | 50 | |
| 51 | 51 | 'use_table_prefix' => false, |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * @param $class |
| 12 | 12 | */ |
| 13 | - function ( $class ) { |
|
| 13 | + function( $class ) { |
|
| 14 | 14 | |
| 15 | 15 | $nameSpace = str_replace( '\\', '/', trim( $class, '\\' ) ) . '.php'; |
| 16 | 16 | $nameSpace = str_replace( 'Qpdb/QueryBuilder/', '', $nameSpace ); |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | use Qpdb\QueryBuilder\QueryBuild; |
| 10 | 10 | |
| 11 | -include_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php'; |
|
| 11 | +include_once $_SERVER[ 'DOCUMENT_ROOT' ] . '/vendor/autoload.php'; |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | $query = QueryBuild::select( 'employees22' ) |
| 15 | - ->fields('lastName, jobTitle, officeCode') |
|
| 15 | + ->fields( 'lastName, jobTitle, officeCode' ) |
|
| 16 | 16 | ->whereEqual( 'jobTitle', "Sales Rep" ) |
| 17 | 17 | ->whereIn( 'officeCode', [ 2, 3, 4 ] ); |
| 18 | 18 | |
@@ -24,12 +24,12 @@ 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 | 29 | $column = trim( $column ); |
| 30 | 30 | |
| 31 | 31 | if ( !$this->validateColumn( $column, $allowedColumns ) ) |
| 32 | - throw new QueryException('Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME); |
|
| 32 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 33 | 33 | |
| 34 | 34 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column ); |
| 35 | 35 | |
@@ -43,12 +43,12 @@ 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 | 48 | $column = trim( $column ); |
| 49 | 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 | + throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 52 | 52 | |
| 53 | 53 | $this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' ); |
| 54 | 54 | |
@@ -60,14 +60,14 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | private function prepareArrayFields( $fieldsArray = array() ) |
| 62 | 62 | { |
| 63 | - $prepareArray = []; |
|
| 63 | + $prepareArray = [ ]; |
|
| 64 | 64 | |
| 65 | 65 | foreach ( $fieldsArray as $field ) { |
| 66 | 66 | if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING ) |
| 67 | 67 | throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD ); |
| 68 | 68 | |
| 69 | 69 | if ( '' !== trim( $field ) ) |
| 70 | - $prepareArray[] = trim( $field ); |
|
| 70 | + $prepareArray[ ] = trim( $field ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $prepareArray; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @return $this |
| 25 | 25 | * @throws QueryException |
| 26 | 26 | */ |
| 27 | - public function groupBy( $column, array $allowedColumns = [] ) |
|
| 27 | + public function groupBy( $column, array $allowedColumns = [ ] ) |
|
| 28 | 28 | { |
| 29 | 29 | $column = trim( $column ); |
| 30 | 30 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return $this |
| 44 | 44 | * @throws QueryException |
| 45 | 45 | */ |
| 46 | - public function groupByDesc( $column, array $allowedColumns = [] ) |
|
| 46 | + public function groupByDesc( $column, array $allowedColumns = [ ] ) |
|
| 47 | 47 | { |
| 48 | 48 | $column = trim( $column ); |
| 49 | 49 | |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $param = $this->validateWhereParam( $param ); |
| 39 | 39 | |
| 40 | - $field = $param[0]; |
|
| 41 | - $value = $param[1]; |
|
| 42 | - $operator = $param[2]; |
|
| 40 | + $field = $param[ 0 ]; |
|
| 41 | + $value = $param[ 1 ]; |
|
| 42 | + $operator = $param[ 2 ]; |
|
| 43 | 43 | |
| 44 | 44 | switch ( $operator ) { |
| 45 | 45 | case 'BETWEEN': |
| 46 | 46 | case 'NOT BETWEEN': |
| 47 | 47 | case '!BETWEEN': |
| 48 | - $min = $value[0]; |
|
| 49 | - $max = $value[1]; |
|
| 48 | + $min = $value[ 0 ]; |
|
| 49 | + $max = $value[ 1 ]; |
|
| 50 | 50 | $body = [ |
| 51 | 51 | $field, |
| 52 | 52 | $operator, |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $pdoArray = array(); |
| 120 | 120 | foreach ( $value as $item ) { |
| 121 | - $pdoArray[] = $this->queryStructure->bindParam( 'a', $item ); |
|
| 121 | + $pdoArray[ ] = $this->queryStructure->bindParam( 'a', $item ); |
|
| 122 | 122 | } |
| 123 | 123 | $body = [ |
| 124 | 124 | $field, |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function getWhereSyntax() |
| 140 | 140 | { |
| 141 | - return $this->getWhereAndHavingSyntax(QueryStructure::WHERE); |
|
| 141 | + return $this->getWhereAndHavingSyntax( QueryStructure::WHERE ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -146,7 +146,7 @@ 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 | /** |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | $where = ''; |
| 162 | 162 | $last_type = 'where_start'; |
| 163 | 163 | foreach ( $this->queryStructure->getElement( $clauseType ) as $where_cond ) { |
| 164 | - $glue = $where_cond['glue']; |
|
| 164 | + $glue = $where_cond[ 'glue' ]; |
|
| 165 | 165 | if ( $last_type == 'where_start' || $last_type == 'start_where_group' ) { |
| 166 | 166 | $glue = ''; |
| 167 | 167 | } |
| 168 | - $where .= ' ' . $glue . ' ' . $where_cond['body']; |
|
| 169 | - $last_type = $where_cond['type']; |
|
| 168 | + $where .= ' ' . $glue . ' ' . $where_cond[ 'body' ]; |
|
| 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 | |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY ); |
| 190 | 190 | |
| 191 | 191 | if ( count( $param ) == 2 ) |
| 192 | - $param[] = '='; |
|
| 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 | } |
@@ -278,7 +278,7 @@ 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 | 283 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
| 284 | 284 | return $this->where( $whereString, $glue ); |
@@ -289,7 +289,7 @@ 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 | 294 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
| 295 | 295 | return $this->where( $whereString, 'OR' ); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | private function where( $param, $glue = 'AND' ) |
| 354 | 354 | { |
| 355 | - return $this->/** @scrutinizer ignore-call */ createCondition($param, $glue, QueryStructure::WHERE ); |
|
| 355 | + return $this->/** @scrutinizer ignore-call */ createCondition( $param, $glue, QueryStructure::WHERE ); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | \ No newline at end of file |
@@ -278,7 +278,7 @@ 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 | 283 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
| 284 | 284 | return $this->having( $whereString, $glue ); |
@@ -289,7 +289,7 @@ 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 | 294 | $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams ); |
| 295 | 295 | return $this->having( $whereString, 'OR' ); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 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 |