@@ -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 | } |
@@ -66,14 +66,12 @@ discard block |
||
| 66 | 66 | $statement === self::QUERY_TYPE_EXPLAIN |
| 67 | 67 | ) { |
| 68 | 68 | return $this->sQuery->fetchAll( $fetchMode ); |
| 69 | - } |
|
| 70 | - elseif( $statement === self::QUERY_TYPE_INSERT || |
|
| 69 | + } elseif( $statement === self::QUERY_TYPE_INSERT || |
|
| 71 | 70 | $statement === self::QUERY_TYPE_UPDATE || |
| 72 | 71 | $statement === self::QUERY_TYPE_DELETE |
| 73 | 72 | ) { |
| 74 | 73 | return $this->sQuery->rowCount(); |
| 75 | - } |
|
| 76 | - else { |
|
| 74 | + } else { |
|
| 77 | 75 | |
| 78 | 76 | return NULL; |
| 79 | 77 | } |
@@ -91,8 +89,9 @@ discard block |
||
| 91 | 89 | $query = trim( str_replace( "\r", " ", $query ) ); |
| 92 | 90 | $statement = self::getQueryStatement( $query ); |
| 93 | 91 | |
| 94 | - if( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
| 95 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
| 92 | + if( $statement === self::QUERY_TYPE_EXPLAIN ) { |
|
| 93 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
| 94 | + } |
|
| 96 | 95 | |
| 97 | 96 | $Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM ); |
| 98 | 97 | |
@@ -112,8 +111,9 @@ discard block |
||
| 112 | 111 | $query = trim( str_replace( "\r", " ", $query ) ); |
| 113 | 112 | $statement = self::getQueryStatement( $query ); |
| 114 | 113 | |
| 115 | - if( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
| 116 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
| 114 | + if( $statement === self::QUERY_TYPE_EXPLAIN ) { |
|
| 115 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | $result = $this->sQuery->fetch( $fetchmode ); |
| 119 | 119 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued, |
@@ -150,24 +150,22 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * Add parameters to the parameter array |
| 152 | 152 | */ |
| 153 | - if( self::isArrayAssoc( $parameters ) ) |
|
| 154 | - $this->bindMore( $parameters ); |
|
| 155 | - else |
|
| 156 | - foreach( $parameters as $key => $val ) |
|
| 153 | + if( self::isArrayAssoc( $parameters ) ) { |
|
| 154 | + $this->bindMore( $parameters ); |
|
| 155 | + } else { |
|
| 156 | + foreach( $parameters as $key => $val ) |
|
| 157 | 157 | $this->parameters[] = array( $key + 1, $val ); |
| 158 | + } |
|
| 158 | 159 | |
| 159 | 160 | if( count( $this->parameters ) ) { |
| 160 | 161 | foreach( $this->parameters as $param => $value ) { |
| 161 | 162 | if( is_int( $value[ 1 ] ) ) { |
| 162 | 163 | $type = \PDO::PARAM_INT; |
| 163 | - } |
|
| 164 | - elseif( is_bool( $value[ 1 ] ) ) { |
|
| 164 | + } elseif( is_bool( $value[ 1 ] ) ) { |
|
| 165 | 165 | $type = \PDO::PARAM_BOOL; |
| 166 | - } |
|
| 167 | - elseif( is_null( $value[ 1 ] ) ) { |
|
| 166 | + } elseif( is_null( $value[ 1 ] ) ) { |
|
| 168 | 167 | $type = \PDO::PARAM_NULL; |
| 169 | - } |
|
| 170 | - else { |
|
| 168 | + } else { |
|
| 171 | 169 | $type = \PDO::PARAM_STR; |
| 172 | 170 | } |
| 173 | 171 | $this->sQuery->bindValue( $value[ 0 ], $value[ 1 ], $type ); |
@@ -246,8 +244,7 @@ discard block |
||
| 246 | 244 | default: |
| 247 | 245 | return self::QUERY_TYPE_OTHER; |
| 248 | 246 | } |
| 249 | - } |
|
| 250 | - else { |
|
| 247 | + } else { |
|
| 251 | 248 | return self::QUERY_TYPE_OTHER; |
| 252 | 249 | } |
| 253 | 250 | } |
@@ -258,7 +255,9 @@ discard block |
||
| 258 | 255 | */ |
| 259 | 256 | public static function isArrayAssoc( array $arr ) |
| 260 | 257 | { |
| 261 | - if( array() === $arr ) return false; |
|
| 258 | + if( array() === $arr ) { |
|
| 259 | + return false; |
|
| 260 | + } |
|
| 262 | 261 | |
| 263 | 262 | return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
| 264 | 263 | } |