@@ -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 GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 31 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) { |
|
| 32 | + throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | $this->queryStructure->setElement( QueryStructure::GROUP_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 GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 51 | + if ( !$this->validateColumn( $column, $allowedColumns ) ) { |
|
| 52 | + throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME ); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | $this->queryStructure->setElement( QueryStructure::GROUP_BY, $column . ' DESC' ); |
| 54 | 56 | |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | */ |
| 74 | 76 | private function getGroupBySyntax() |
| 75 | 77 | { |
| 76 | - if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) ) |
|
| 77 | - return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' ); |
|
| 78 | + if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) ) { |
|
| 79 | + return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' ); |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | 82 | return ''; |
| 80 | 83 | } |
@@ -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 | |
@@ -87,7 +87,9 @@ discard block |
||
| 87 | 87 | $newArray = array(); |
| 88 | 88 | foreach ( $brutArray as $value ) { |
| 89 | 89 | $value = trim( $value ); |
| 90 | - if ( '' !== $value ) $newArray[] = $value; |
|
| 90 | + if ( '' !== $value ) { |
|
| 91 | + $newArray[] = $value; |
|
| 92 | + } |
|
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | return $newArray; |
@@ -137,8 +139,9 @@ discard block |
||
| 137 | 139 | $characters = 'abcdefghijklmnopqrstuvwxyz'; |
| 138 | 140 | $charactersLength = strlen( $characters ); |
| 139 | 141 | $randomString = ''; |
| 140 | - for ( $i = 0; $i < $length; $i++ ) |
|
| 141 | - $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
| 142 | + for ( $i = 0; $i < $length; $i++ ) { |
|
| 143 | + $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
| 144 | + } |
|
| 142 | 145 | |
| 143 | 146 | return str_shuffle( $randomString ); |
| 144 | 147 | } |
@@ -146,8 +149,9 @@ discard block |
||
| 146 | 149 | public static function limitString( $rowCount, $offset = null ) |
| 147 | 150 | { |
| 148 | 151 | $rowCount = intval( $rowCount ); |
| 149 | - if ( is_null( $offset ) ) |
|
| 150 | - return $rowCount; |
|
| 152 | + if ( is_null( $offset ) ) { |
|
| 153 | + return $rowCount; |
|
| 154 | + } |
|
| 151 | 155 | $offset = intval( $offset ); |
| 152 | 156 | |
| 153 | 157 | return "$offset, $rowCount"; |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( !in_array( $subparts[0], $columns ) ) { |
|
| 64 | + if ( !in_array( $subparts[ 0 ], $columns ) ) { |
|
| 65 | 65 | // Column name is invalid. |
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( count( $subparts ) == 2 && !in_array( strtoupper( $subparts[1] ), array( 'ASC', 'DESC' ) ) ) { |
|
| 69 | + if ( count( $subparts ) == 2 && !in_array( strtoupper( $subparts[ 1 ] ), array( 'ASC', 'DESC' ) ) ) { |
|
| 70 | 70 | // ASC or DESC is invalid |
| 71 | 71 | return false; |
| 72 | 72 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $newArray = array(); |
| 88 | 88 | foreach ( $brutArray as $value ) { |
| 89 | 89 | $value = trim( $value ); |
| 90 | - if ( '' !== $value ) $newArray[] = $value; |
|
| 90 | + if ( '' !== $value ) $newArray[ ] = $value; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $newArray; |
@@ -85,8 +85,9 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $this->syntaxEL = $this->init(); |
| 87 | 87 | |
| 88 | - foreach ( $this->syntaxEL as $name => $value ) |
|
| 89 | - $this->typeEL[ $name ] = gettype( $value ); |
|
| 88 | + foreach ( $this->syntaxEL as $name => $value ) { |
|
| 89 | + $this->typeEL[ $name ] = gettype( $value ); |
|
| 90 | + } |
|
| 90 | 91 | |
| 91 | 92 | } |
| 92 | 93 | |
@@ -172,16 +173,19 @@ discard block |
||
| 172 | 173 | */ |
| 173 | 174 | public function setElement( $name, $value ) |
| 174 | 175 | { |
| 175 | - if ( !array_key_exists( $name, $this->syntaxEL ) ) |
|
| 176 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
| 176 | + if ( !array_key_exists( $name, $this->syntaxEL ) ) { |
|
| 177 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
| 178 | + } |
|
| 177 | 179 | |
| 178 | - if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) |
|
| 179 | - return true; |
|
| 180 | + if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) { |
|
| 181 | + return true; |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
|
| 182 | - $this->syntaxEL[ $name ][] = $value; |
|
| 183 | - else |
|
| 184 | - $this->syntaxEL[ $name ] = $value; |
|
| 184 | + if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) { |
|
| 185 | + $this->syntaxEL[ $name ][] = $value; |
|
| 186 | + } else { |
|
| 187 | + $this->syntaxEL[ $name ] = $value; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | return true; |
| 187 | 191 | } |
@@ -194,8 +198,9 @@ discard block |
||
| 194 | 198 | */ |
| 195 | 199 | public function replaceElement( $elementName, $elementValue ) |
| 196 | 200 | { |
| 197 | - if ( !array_key_exists( $elementName, $this->syntaxEL ) ) |
|
| 198 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
| 201 | + if ( !array_key_exists( $elementName, $this->syntaxEL ) ) { |
|
| 202 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
| 203 | + } |
|
| 199 | 204 | |
| 200 | 205 | $this->syntaxEL[ $elementName ] = $elementValue; |
| 201 | 206 | } |
@@ -243,11 +248,13 @@ discard block |
||
| 243 | 248 | */ |
| 244 | 249 | public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
| 245 | 250 | { |
| 246 | - if ( !count( $params ) ) |
|
| 247 | - return $expression; |
|
| 251 | + if ( !count( $params ) ) { |
|
| 252 | + return $expression; |
|
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if ( strpos( $expression, $search ) === false ) |
|
| 250 | - return $expression; |
|
| 255 | + if ( strpos( $expression, $search ) === false ) { |
|
| 256 | + return $expression; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
| 253 | 260 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @var array |
| 62 | 62 | */ |
| 63 | - private static $usedInstanceIds = []; |
|
| 63 | + private static $usedInstanceIds = [ ]; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * @var array |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | while ( in_array( $instance, self::$usedInstanceIds ) ) { |
| 133 | 133 | $instance = QueryHelper::random( 7 ); |
| 134 | 134 | } |
| 135 | - self::$usedInstanceIds[] = $instance; |
|
| 135 | + self::$usedInstanceIds[ ] = $instance; |
|
| 136 | 136 | |
| 137 | 137 | return $instance; |
| 138 | 138 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | return true; |
| 180 | 180 | |
| 181 | 181 | if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
| 182 | - $this->syntaxEL[ $name ][] = $value; |
|
| 182 | + $this->syntaxEL[ $name ][ ] = $value; |
|
| 183 | 183 | else |
| 184 | 184 | $this->syntaxEL[ $name ] = $value; |
| 185 | 185 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param string $search |
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | - public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
|
| 244 | + public function bindParamsExpression( $expression, array $params = [ ], $search = '?' ) |
|
| 245 | 245 | { |
| 246 | 246 | if ( !count( $params ) ) |
| 247 | 247 | return $expression; |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
| 253 | 253 | |
| 254 | 254 | $i = 0; |
| 255 | - $arrayReturn = []; |
|
| 255 | + $arrayReturn = [ ]; |
|
| 256 | 256 | $expressionToArray = explode( $search, $expression ); |
| 257 | 257 | |
| 258 | 258 | foreach ( $expressionToArray as $sub ) { |
| 259 | - $arrayReturn[] = $sub; |
|
| 260 | - $arrayReturn[] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
| 259 | + $arrayReturn[ ] = $sub; |
|
| 260 | + $arrayReturn[ ] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
| 261 | 261 | $i++; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function getMasterConnection() |
| 44 | 44 | { |
| 45 | - if ( !is_a( $this->pdoMaster, \PDO::class ) ) |
|
| 46 | - $this->pdoMaster = $this->connect( $this->config->getMasterDataConnect() ); |
|
| 45 | + if ( !is_a( $this->pdoMaster, \PDO::class ) ) { |
|
| 46 | + $this->pdoMaster = $this->connect( $this->config->getMasterDataConnect() ); |
|
| 47 | + } |
|
| 47 | 48 | |
| 48 | 49 | return $this->pdoMaster; |
| 49 | 50 | } |
@@ -53,11 +54,13 @@ discard block |
||
| 53 | 54 | */ |
| 54 | 55 | public function getSlaveConnection() |
| 55 | 56 | { |
| 56 | - if ( !$this->config->getReplicationEnable() ) |
|
| 57 | - return $this->getMasterConnection(); |
|
| 57 | + if ( !$this->config->getReplicationEnable() ) { |
|
| 58 | + return $this->getMasterConnection(); |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | - if ( !is_a( $this->pdoSlave, \PDO::class ) ) |
|
| 60 | - $this->pdoSlave = $this->connect( $this->config->getSlaveDataConnect() ); |
|
| 61 | + if ( !is_a( $this->pdoSlave, \PDO::class ) ) { |
|
| 62 | + $this->pdoSlave = $this->connect( $this->config->getSlaveDataConnect() ); |
|
| 63 | + } |
|
| 61 | 64 | |
| 62 | 65 | return $this->pdoSlave; |
| 63 | 66 | } |
@@ -70,8 +73,9 @@ discard block |
||
| 70 | 73 | { |
| 71 | 74 | $statement = trim( strtolower( $statement ) ); |
| 72 | 75 | |
| 73 | - if ( $statement === DbService::QUERY_TYPE_SELECT ) |
|
| 74 | - return $this->getSlaveConnection(); |
|
| 76 | + if ( $statement === DbService::QUERY_TYPE_SELECT ) { |
|
| 77 | + return $this->getSlaveConnection(); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | return $this->getMasterConnection(); |
| 77 | 81 | } |
@@ -99,10 +99,10 @@ |
||
| 99 | 99 | */ |
| 100 | 100 | private function connect( $dataConnect ) |
| 101 | 101 | { |
| 102 | - $dsn = 'mysql:dbname=' . $dataConnect["dbname"] . ';host=' . $dataConnect["host"] . ''; |
|
| 102 | + $dsn = 'mysql:dbname=' . $dataConnect[ "dbname" ] . ';host=' . $dataConnect[ "host" ] . ''; |
|
| 103 | 103 | try { |
| 104 | 104 | |
| 105 | - $pdo = new \PDO( $dsn, $dataConnect["user"], $dataConnect["password"], |
|
| 105 | + $pdo = new \PDO( $dsn, $dataConnect[ "user" ], $dataConnect[ "password" ], |
|
| 106 | 106 | array( \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" ) |
| 107 | 107 | ); |
| 108 | 108 | |
@@ -60,10 +60,11 @@ discard block |
||
| 60 | 60 | private function __construct() |
| 61 | 61 | { |
| 62 | 62 | $vendorCfg = __DIR__ . '/../../../../../vendor-cfg/qpdb_db_config.php'; |
| 63 | - if(file_exists($vendorCfg)) |
|
| 64 | - $this->dbConfig = require $vendorCfg; |
|
| 65 | - else |
|
| 66 | - $this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php'; |
|
| 63 | + if(file_exists($vendorCfg)) { |
|
| 64 | + $this->dbConfig = require $vendorCfg; |
|
| 65 | + } else { |
|
| 66 | + $this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php'; |
|
| 67 | + } |
|
| 67 | 68 | |
| 68 | 69 | $this->buildConfig(); |
| 69 | 70 | } |
@@ -146,8 +147,9 @@ discard block |
||
| 146 | 147 | |
| 147 | 148 | public function useTablePrefix() |
| 148 | 149 | { |
| 149 | - if ( !empty( $this->dbConfig['use_table_prefix'] ) ) |
|
| 150 | - return $this->dbConfig['use_table_prefix']; |
|
| 150 | + if ( !empty( $this->dbConfig['use_table_prefix'] ) ) { |
|
| 151 | + return $this->dbConfig['use_table_prefix']; |
|
| 152 | + } |
|
| 151 | 153 | |
| 152 | 154 | return false; |
| 153 | 155 | } |
@@ -182,8 +184,9 @@ discard block |
||
| 182 | 184 | private function readMasterDataConnect() |
| 183 | 185 | { |
| 184 | 186 | |
| 185 | - if ( !isset( $this->dbConfig['master_data_connect'][0] ) ) |
|
| 186 | - throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING ); |
|
| 187 | + if ( !isset( $this->dbConfig['master_data_connect'][0] ) ) { |
|
| 188 | + throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING ); |
|
| 189 | + } |
|
| 187 | 190 | |
| 188 | 191 | $dataConnection = $this->dbConfig['master_data_connect']; |
| 189 | 192 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | private function __construct() |
| 61 | 61 | { |
| 62 | 62 | $vendorCfg = __DIR__ . '/../../../../../vendor-cfg/qpdb_db_config.php'; |
| 63 | - if(file_exists($vendorCfg)) |
|
| 63 | + if ( file_exists( $vendorCfg ) ) |
|
| 64 | 64 | $this->dbConfig = require $vendorCfg; |
| 65 | 65 | else |
| 66 | 66 | $this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php'; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function getLogConfig() |
| 111 | 111 | { |
| 112 | - return $this->dbConfig['db_log']; |
|
| 112 | + return $this->dbConfig[ 'db_log' ]; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -146,21 +146,21 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | public function useTablePrefix() |
| 148 | 148 | { |
| 149 | - if ( !empty( $this->dbConfig['use_table_prefix'] ) ) |
|
| 150 | - return $this->dbConfig['use_table_prefix']; |
|
| 149 | + if ( !empty( $this->dbConfig[ 'use_table_prefix' ] ) ) |
|
| 150 | + return $this->dbConfig[ 'use_table_prefix' ]; |
|
| 151 | 151 | |
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function getTablePrefix() |
| 156 | 156 | { |
| 157 | - return $this->dbConfig['table_prefix']; |
|
| 157 | + return $this->dbConfig[ 'table_prefix' ]; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | private function buildConfig() |
| 162 | 162 | { |
| 163 | - $this->replicationEnable = $this->dbConfig['replicationEnable']; |
|
| 163 | + $this->replicationEnable = $this->dbConfig[ 'replicationEnable' ]; |
|
| 164 | 164 | $this->readMasterDataConnect(); |
| 165 | 165 | $this->readSlaveDataConnect(); |
| 166 | 166 | $this->configLogger(); |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | private function configLogger() |
| 170 | 170 | { |
| 171 | - $this->enableLogErrors = $this->dbConfig['db_log']['enable_log_errors']; |
|
| 172 | - $this->enableLogQueryDuration = $this->dbConfig['db_log']['enable_log_query_duration']; |
|
| 173 | - $this->logPathErrors = $this->dbConfig['db_log']['log_path_errors']; |
|
| 174 | - $this->logPathQueryDuration = $this->dbConfig['db_log']['log_path_query_duration']; |
|
| 171 | + $this->enableLogErrors = $this->dbConfig[ 'db_log' ][ 'enable_log_errors' ]; |
|
| 172 | + $this->enableLogQueryDuration = $this->dbConfig[ 'db_log' ][ 'enable_log_query_duration' ]; |
|
| 173 | + $this->logPathErrors = $this->dbConfig[ 'db_log' ][ 'log_path_errors' ]; |
|
| 174 | + $this->logPathQueryDuration = $this->dbConfig[ 'db_log' ][ 'log_path_query_duration' ]; |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,19 +182,19 @@ discard block |
||
| 182 | 182 | private function readMasterDataConnect() |
| 183 | 183 | { |
| 184 | 184 | |
| 185 | - if ( !isset( $this->dbConfig['master_data_connect'][0] ) ) |
|
| 185 | + if ( !isset( $this->dbConfig[ 'master_data_connect' ][ 0 ] ) ) |
|
| 186 | 186 | throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING ); |
| 187 | 187 | |
| 188 | - $dataConnection = $this->dbConfig['master_data_connect']; |
|
| 188 | + $dataConnection = $this->dbConfig[ 'master_data_connect' ]; |
|
| 189 | 189 | |
| 190 | 190 | if ( !$this->replicationEnable || count( $dataConnection ) == 1 ) { |
| 191 | - $this->masterDataConnect = $dataConnection[0]; |
|
| 191 | + $this->masterDataConnect = $dataConnection[ 0 ]; |
|
| 192 | 192 | |
| 193 | 193 | return true; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | shuffle( $dataConnection ); |
| 197 | - $this->masterDataConnect = $dataConnection[0]; |
|
| 197 | + $this->masterDataConnect = $dataConnection[ 0 ]; |
|
| 198 | 198 | |
| 199 | 199 | return true; |
| 200 | 200 | } |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | private function readSlaveDataConnect() |
| 207 | 207 | { |
| 208 | 208 | |
| 209 | - if ( !isset( $this->dbConfig['slave_data_connect'][0] ) ) { |
|
| 209 | + if ( !isset( $this->dbConfig[ 'slave_data_connect' ][ 0 ] ) ) { |
|
| 210 | 210 | $this->slaveDataConnect = $this->masterDataConnect; |
| 211 | 211 | |
| 212 | 212 | return true; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $dataConnection = $this->dbConfig['slave_data_connect']; |
|
| 215 | + $dataConnection = $this->dbConfig[ 'slave_data_connect' ]; |
|
| 216 | 216 | |
| 217 | 217 | shuffle( $dataConnection ); |
| 218 | - $this->slaveDataConnect = $dataConnection[0]; |
|
| 218 | + $this->slaveDataConnect = $dataConnection[ 0 ]; |
|
| 219 | 219 | |
| 220 | 220 | return true; |
| 221 | 221 | } |
@@ -110,8 +110,9 @@ |
||
| 110 | 110 | if ( |
| 111 | 111 | $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && |
| 112 | 112 | !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) |
| 113 | - ) |
|
| 114 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 113 | + ) { |
|
| 114 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 115 | + } |
|
| 115 | 116 | |
| 116 | 117 | return DbService::getInstance()->query( |
| 117 | 118 | $this->getSyntax(), |
@@ -52,47 +52,47 @@ |
||
| 52 | 52 | /** |
| 53 | 53 | * Explain |
| 54 | 54 | */ |
| 55 | - $syntax[] = $this->getExplainSyntax(); |
|
| 55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * UPDATE statement |
| 59 | 59 | */ |
| 60 | - $syntax[] = $this->statement; |
|
| 60 | + $syntax[ ] = $this->statement; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * PRIORITY |
| 64 | 64 | */ |
| 65 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * IGNORE clause |
| 69 | 69 | */ |
| 70 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
| 70 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * TABLE update |
| 74 | 74 | */ |
| 75 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 75 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * FIELDS update |
| 79 | 79 | */ |
| 80 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
| 80 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * WHERE clause |
| 84 | 84 | */ |
| 85 | - $syntax[] = $this->getWhereSyntax(); |
|
| 85 | + $syntax[ ] = $this->getWhereSyntax(); |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * ORDER BY clause |
| 89 | 89 | */ |
| 90 | - $syntax[] = $this->getOrderBySyntax(); |
|
| 90 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * LIMIT clause |
| 94 | 94 | */ |
| 95 | - $syntax[] = $this->getLimitSyntax(); |
|
| 95 | + $syntax[ ] = $this->getLimitSyntax(); |
|
| 96 | 96 | |
| 97 | 97 | $syntax = implode( ' ', $syntax ); |
| 98 | 98 | |
@@ -55,8 +55,9 @@ discard block |
||
| 55 | 55 | $this->queryStructure->setElement( QueryStructure::TABLE, $tableName ); |
| 56 | 56 | |
| 57 | 57 | $tableSelectParams = $table->getBindParams(); |
| 58 | - foreach ( $tableSelectParams as $key => $value ) |
|
| 59 | - $this->queryStructure->setParams( $key, $value ); |
|
| 58 | + foreach ( $tableSelectParams as $key => $value ) { |
|
| 59 | + $this->queryStructure->setParams( $key, $value ); |
|
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | } |
| 62 | 63 | } |
@@ -107,8 +108,9 @@ discard block |
||
| 107 | 108 | $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //??? |
| 108 | 109 | } |
| 109 | 110 | |
| 110 | - if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) |
|
| 111 | - $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
| 111 | + if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) { |
|
| 112 | + $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | 115 | $syntax = array(); |
| 114 | 116 | |
@@ -190,8 +192,9 @@ discard block |
||
| 190 | 192 | return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
| 191 | 193 | break; |
| 192 | 194 | case $this->queryStructure->getElement( QueryStructure::FIRST ): |
| 193 | - if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) ) |
|
| 194 | - return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
| 195 | + if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) ) { |
|
| 196 | + return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
| 197 | + } |
|
| 195 | 198 | |
| 196 | 199 | return DbService::getInstance()->row( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
| 197 | 200 | break; |
@@ -115,62 +115,62 @@ |
||
| 115 | 115 | /** |
| 116 | 116 | * Explain |
| 117 | 117 | */ |
| 118 | - $syntax[] = $this->getExplainSyntax(); |
|
| 118 | + $syntax[ ] = $this->getExplainSyntax(); |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * SELECT statement |
| 122 | 122 | */ |
| 123 | - $syntax[] = $this->statement; |
|
| 123 | + $syntax[ ] = $this->statement; |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * PRIORITY |
| 127 | 127 | */ |
| 128 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 128 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * DISTINCT clause |
| 132 | 132 | */ |
| 133 | - $syntax[] = $this->getDistinctSyntax(); |
|
| 133 | + $syntax[ ] = $this->getDistinctSyntax(); |
|
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * FIELDS |
| 137 | 137 | */ |
| 138 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
| 138 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * FROM table or queryStructure |
| 142 | 142 | */ |
| 143 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 143 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * JOIN CLAUSES |
| 147 | 147 | */ |
| 148 | - $syntax[] = $this->getJoinSyntax(); |
|
| 148 | + $syntax[ ] = $this->getJoinSyntax(); |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * WHERE clause |
| 152 | 152 | */ |
| 153 | - $syntax[] = $this->getWhereSyntax(); |
|
| 153 | + $syntax[ ] = $this->getWhereSyntax(); |
|
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * GROUP BY clause |
| 157 | 157 | */ |
| 158 | - $syntax[] = $this->getGroupBySyntax(); |
|
| 158 | + $syntax[ ] = $this->getGroupBySyntax(); |
|
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * HAVING clause |
| 162 | 162 | */ |
| 163 | - $syntax[] = $this->getHavingSyntax(); |
|
| 163 | + $syntax[ ] = $this->getHavingSyntax(); |
|
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * ORDER BY clause |
| 167 | 167 | */ |
| 168 | - $syntax[] = $this->getOrderBySyntax(); |
|
| 168 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * LIMIT clause |
| 172 | 172 | */ |
| 173 | - $syntax[] = $this->getLimitSyntax(); |
|
| 173 | + $syntax[ ] = $this->getLimitSyntax(); |
|
| 174 | 174 | |
| 175 | 175 | $syntax = implode( ' ', $syntax ); |
| 176 | 176 | |
@@ -99,8 +99,9 @@ |
||
| 99 | 99 | if ( |
| 100 | 100 | $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && |
| 101 | 101 | !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) |
| 102 | - ) |
|
| 103 | - throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 102 | + ) { |
|
| 103 | + throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 104 | + } |
|
| 104 | 105 | |
| 105 | 106 | return DbService::getInstance()->query( |
| 106 | 107 | $this->getSyntax(), |
@@ -52,37 +52,37 @@ |
||
| 52 | 52 | /** |
| 53 | 53 | * Explain |
| 54 | 54 | */ |
| 55 | - $syntax[] = $this->getExplainSyntax(); |
|
| 55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * UPDATE statement |
| 59 | 59 | */ |
| 60 | - $syntax[] = $this->statement; |
|
| 60 | + $syntax[ ] = $this->statement; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * PRIORITY |
| 64 | 64 | */ |
| 65 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * TABLE update |
| 69 | 69 | */ |
| 70 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 70 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * WHERE clause |
| 74 | 74 | */ |
| 75 | - $syntax[] = $this->getWhereSyntax(); |
|
| 75 | + $syntax[ ] = $this->getWhereSyntax(); |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * ORDER BY clause |
| 79 | 79 | */ |
| 80 | - $syntax[] = $this->getOrderBySyntax(); |
|
| 80 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * LIMIT clause |
| 84 | 84 | */ |
| 85 | - $syntax[] = $this->getLimitSyntax(); |
|
| 85 | + $syntax[ ] = $this->getLimitSyntax(); |
|
| 86 | 86 | |
| 87 | 87 | $syntax = implode( ' ', $syntax ); |
| 88 | 88 | |
@@ -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, |