@@ -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; |
@@ -45,22 +45,26 @@ |
||
| 45 | 45 | { |
| 46 | 46 | $table = trim( $table ); |
| 47 | 47 | |
| 48 | - if ( '' === $table ) |
|
| 49 | - throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 48 | + if ( '' === $table ) { |
|
| 49 | + throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 50 | + } |
|
| 50 | 51 | |
| 51 | - if ( DbConfig::getInstance()->useTablePrefix() ) |
|
| 52 | - $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
| 52 | + if ( DbConfig::getInstance()->useTablePrefix() ) { |
|
| 53 | + $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | 56 | return $table; |
| 55 | 57 | } |
| 56 | 58 | |
| 57 | 59 | private function validateTableSubQuery( $table ) |
| 58 | 60 | { |
| 59 | - if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) |
|
| 60 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 61 | + if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) { |
|
| 62 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 63 | + } |
|
| 61 | 64 | |
| 62 | - if ( !is_a( $table, QuerySelect::class ) ) |
|
| 63 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 65 | + if ( !is_a( $table, QuerySelect::class ) ) { |
|
| 66 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | return $table; |
| 66 | 70 | } |
@@ -85,12 +85,10 @@ |
||
| 85 | 85 | $fh = fopen( $log, 'a+' ); |
| 86 | 86 | fwrite( $fh, $messageFormat ); |
| 87 | 87 | fclose( $fh ); |
| 88 | - } |
|
| 89 | - else { |
|
| 88 | + } else { |
|
| 90 | 89 | $this->edit( $log, $messageFormat ); |
| 91 | 90 | } |
| 92 | - } |
|
| 93 | - else { |
|
| 91 | + } else { |
|
| 94 | 92 | if ( mkdir( $this->path, 0777 ) === true ) { |
| 95 | 93 | $this->write( $message ); |
| 96 | 94 | } |
@@ -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 | |
@@ -87,8 +87,9 @@ discard block |
||
| 87 | 87 | $newArray = array(); |
| 88 | 88 | foreach ( $brutArray as $value ) { |
| 89 | 89 | $value = trim( $value ); |
| 90 | - if ( '' !== $value ) |
|
| 91 | - $newArray[] = $value; |
|
| 90 | + if ( '' !== $value ) { |
|
| 91 | + $newArray[] = $value; |
|
| 92 | + } |
|
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | return $newArray; |
@@ -138,8 +139,9 @@ discard block |
||
| 138 | 139 | $characters = 'abcdefghijklmnopqrstuvwxyz'; |
| 139 | 140 | $charactersLength = strlen( $characters ); |
| 140 | 141 | $randomString = ''; |
| 141 | - for ( $i = 0; $i < $length; $i++ ) |
|
| 142 | - $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
| 142 | + for ( $i = 0; $i < $length; $i++ ) { |
|
| 143 | + $randomString .= $characters[ rand( 0, $charactersLength - 1 ) ]; |
|
| 144 | + } |
|
| 143 | 145 | |
| 144 | 146 | return str_shuffle( $randomString ); |
| 145 | 147 | } |
@@ -147,8 +149,9 @@ discard block |
||
| 147 | 149 | public static function limitString( $rowCount, $offset = null ) |
| 148 | 150 | { |
| 149 | 151 | $rowCount = intval( $rowCount ); |
| 150 | - if ( is_null( $offset ) ) |
|
| 151 | - return $rowCount; |
|
| 152 | + if ( is_null( $offset ) ) { |
|
| 153 | + return $rowCount; |
|
| 154 | + } |
|
| 152 | 155 | $offset = intval( $offset ); |
| 153 | 156 | |
| 154 | 157 | return "$offset, $rowCount"; |
@@ -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 | } |
@@ -28,8 +28,9 @@ |
||
| 28 | 28 | |
| 29 | 29 | protected function getExplainSyntax() |
| 30 | 30 | { |
| 31 | - if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) ) |
|
| 32 | - return 'EXPLAIN'; |
|
| 31 | + if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) ) { |
|
| 32 | + return 'EXPLAIN'; |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | return ''; |
| 35 | 36 | } |
@@ -106,8 +106,9 @@ |
||
| 106 | 106 | */ |
| 107 | 107 | public function execute() |
| 108 | 108 | { |
| 109 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
| 110 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 109 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
| 110 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 111 | + } |
|
| 111 | 112 | |
| 112 | 113 | return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
| 113 | 114 | } |
@@ -96,8 +96,9 @@ |
||
| 96 | 96 | public function execute() |
| 97 | 97 | { |
| 98 | 98 | |
| 99 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
| 100 | - throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 99 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
| 100 | + throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
| 101 | + } |
|
| 101 | 102 | |
| 102 | 103 | return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
| 103 | 104 | |