@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * @param integer $type Type of given value defined in \Aimeos\MW\DB\Stmt\Base as constant |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | - public function bind( $position, $value, $type = \Aimeos\MW\DB\Statement\Base::PARAM_STR); |
|
| 31 | + public function bind( $position, $value, $type = \Aimeos\MW\DB\Statement\Base::PARAM_STR ); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Executes the statement. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | try { |
| 50 | 50 | return $this->statement->rowCount(); |
| 51 | - } catch ( \PDOException $e ) { |
|
| 51 | + } catch( \PDOException $e ) { |
|
| 52 | 52 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | try { |
| 67 | 67 | return $this->statement->fetch( $this->style[$style] ); |
| 68 | - } catch ( \PDOException $e ) { |
|
| 68 | + } catch( \PDOException $e ) { |
|
| 69 | 69 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | try { |
| 82 | 82 | $this->statement->closeCursor(); |
| 83 | - } catch ( \PDOException $e ) { |
|
| 83 | + } catch( \PDOException $e ) { |
|
| 84 | 84 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | try { |
| 97 | 97 | return $this->statement->nextRowset(); |
| 98 | - } catch ( \PDOException $e ) { |
|
| 98 | + } catch( \PDOException $e ) { |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -46,9 +46,12 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function affectedRows() |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try |
|
| 50 | + { |
|
| 50 | 51 | return $this->statement->rowCount(); |
| 51 | - } catch ( \PDOException $e ) { |
|
| 52 | + } |
|
| 53 | + catch ( \PDOException $e ) |
|
| 54 | + { |
|
| 52 | 55 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 53 | 56 | } |
| 54 | 57 | } |
@@ -63,9 +66,12 @@ discard block |
||
| 63 | 66 | */ |
| 64 | 67 | public function fetch( $style = \Aimeos\MW\DB\Result\Base::FETCH_ASSOC ) |
| 65 | 68 | { |
| 66 | - try { |
|
| 69 | + try |
|
| 70 | + { |
|
| 67 | 71 | return $this->statement->fetch( $this->style[$style] ); |
| 68 | - } catch ( \PDOException $e ) { |
|
| 72 | + } |
|
| 73 | + catch ( \PDOException $e ) |
|
| 74 | + { |
|
| 69 | 75 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 70 | 76 | } |
| 71 | 77 | } |
@@ -78,9 +84,12 @@ discard block |
||
| 78 | 84 | */ |
| 79 | 85 | public function finish() |
| 80 | 86 | { |
| 81 | - try { |
|
| 87 | + try |
|
| 88 | + { |
|
| 82 | 89 | $this->statement->closeCursor(); |
| 83 | - } catch ( \PDOException $e ) { |
|
| 90 | + } |
|
| 91 | + catch ( \PDOException $e ) |
|
| 92 | + { |
|
| 84 | 93 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 85 | 94 | } |
| 86 | 95 | } |
@@ -93,9 +102,12 @@ discard block |
||
| 93 | 102 | */ |
| 94 | 103 | public function nextResult() |
| 95 | 104 | { |
| 96 | - try { |
|
| 105 | + try |
|
| 106 | + { |
|
| 97 | 107 | return $this->statement->nextRowset(); |
| 98 | - } catch ( \PDOException $e ) { |
|
| 108 | + } |
|
| 109 | + catch ( \PDOException $e ) |
|
| 110 | + { |
|
| 99 | 111 | return false; |
| 100 | 112 | } |
| 101 | 113 | } |
@@ -30,15 +30,15 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | static public function createManager( \Aimeos\MW\Config\Iface $config, $type = 'PDO' ) |
| 32 | 32 | { |
| 33 | - $classname = '\\Aimeos\\MW\\DB\\Manager\\' . $type; |
|
| 34 | - $filename = 'MW/DB/Manager/' . $type . '.php'; |
|
| 33 | + $classname = '\\Aimeos\\MW\\DB\\Manager\\'.$type; |
|
| 34 | + $filename = 'MW/DB/Manager/'.$type.'.php'; |
|
| 35 | 35 | |
| 36 | 36 | $paths = explode( PATH_SEPARATOR, get_include_path() ); |
| 37 | 37 | |
| 38 | 38 | foreach( $paths as $path ) |
| 39 | 39 | { |
| 40 | - $file = $path . DIRECTORY_SEPARATOR . $filename; |
|
| 41 | - if( file_exists( $file ) === true && ( include_once $file ) !== false && class_exists($classname)) { |
|
| 40 | + $file = $path.DIRECTORY_SEPARATOR.$filename; |
|
| 41 | + if( file_exists( $file ) === true && ( include_once $file ) !== false && class_exists( $classname ) ) { |
|
| 42 | 42 | return new $classname( $config ); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -88,7 +88,8 @@ |
||
| 88 | 88 | return array_pop( $this->connections[$name] ); |
| 89 | 89 | |
| 90 | 90 | } |
| 91 | - catch( \Exception $e ) { |
|
| 91 | + catch( \Exception $e ) |
|
| 92 | + { |
|
| 92 | 93 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
| 93 | 94 | } |
| 94 | 95 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | try |
| 74 | 74 | { |
| 75 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
| 75 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
| 76 | 76 | |
| 77 | 77 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
| 78 | 78 | { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $this->count[$name] = 0; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
| 83 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
| 84 | 84 | |
| 85 | 85 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
| 86 | 86 | { |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function createConnection( $name, $adapter ) |
| 128 | 128 | { |
| 129 | - $params = $this->config->get( 'resource/' . $name ); |
|
| 129 | + $params = $this->config->get( 'resource/'.$name ); |
|
| 130 | 130 | |
| 131 | - $params['user'] = $this->config->get( 'resource/' . $name . '/username' ); |
|
| 132 | - $params['dbname'] = $this->config->get( 'resource/' . $name . '/database' ); |
|
| 131 | + $params['user'] = $this->config->get( 'resource/'.$name.'/username' ); |
|
| 132 | + $params['dbname'] = $this->config->get( 'resource/'.$name.'/database' ); |
|
| 133 | 133 | |
| 134 | - if( ( $socket = $this->config->get( 'resource/' . $name . '/socket' ) ) != null ) { |
|
| 134 | + if( ( $socket = $this->config->get( 'resource/'.$name.'/socket' ) ) != null ) { |
|
| 135 | 135 | $params['unix_socket'] = $socket; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | default: $params['driver'] = $adapter; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $stmts = $this->config->get( 'resource/' . $name . '/stmt', [] ); |
|
| 147 | + $stmts = $this->config->get( 'resource/'.$name.'/stmt', [] ); |
|
| 148 | 148 | |
| 149 | 149 | return new \Aimeos\MW\DB\Connection\DBAL( $params, $stmts ); |
| 150 | 150 | } |
@@ -88,7 +88,8 @@ discard block |
||
| 88 | 88 | return array_pop( $this->connections[$name] ); |
| 89 | 89 | |
| 90 | 90 | } |
| 91 | - catch( \PDOException $e ) { |
|
| 91 | + catch( \PDOException $e ) |
|
| 92 | + { |
|
| 92 | 93 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
| 93 | 94 | } |
| 94 | 95 | } |
@@ -131,8 +132,7 @@ discard block |
||
| 131 | 132 | { |
| 132 | 133 | $dsn .= isset( $host ) ? ';host=' . $host : ''; |
| 133 | 134 | $dsn .= isset( $port ) ? ';port=' . $port : ''; |
| 134 | - } |
|
| 135 | - else |
|
| 135 | + } else |
|
| 136 | 136 | { |
| 137 | 137 | $dsn .= ';unix_socket=' . $sock; |
| 138 | 138 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | try |
| 75 | 75 | { |
| 76 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
| 76 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
| 77 | 77 | |
| 78 | 78 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
| 79 | 79 | { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $this->count[$name] = 0; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
| 84 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
| 85 | 85 | |
| 86 | 86 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
| 87 | 87 | { |
@@ -127,27 +127,27 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function createConnection( $name, $adapter ) |
| 129 | 129 | { |
| 130 | - $host = $this->config->get( 'resource/' . $name . '/host' ); |
|
| 131 | - $port = $this->config->get( 'resource/' . $name . '/port' ); |
|
| 132 | - $user = $this->config->get( 'resource/' . $name . '/username' ); |
|
| 133 | - $pass = $this->config->get( 'resource/' . $name . '/password' ); |
|
| 134 | - $sock = $this->config->get( 'resource/' . $name . '/socket' ); |
|
| 135 | - $dbase = $this->config->get( 'resource/' . $name . '/database' ); |
|
| 136 | - $persist = $this->config->get( 'resource/' . $name . '/opt-persistent', false ); |
|
| 137 | - |
|
| 138 | - $dsn = $adapter . ':dbname=' . $dbase; |
|
| 130 | + $host = $this->config->get( 'resource/'.$name.'/host' ); |
|
| 131 | + $port = $this->config->get( 'resource/'.$name.'/port' ); |
|
| 132 | + $user = $this->config->get( 'resource/'.$name.'/username' ); |
|
| 133 | + $pass = $this->config->get( 'resource/'.$name.'/password' ); |
|
| 134 | + $sock = $this->config->get( 'resource/'.$name.'/socket' ); |
|
| 135 | + $dbase = $this->config->get( 'resource/'.$name.'/database' ); |
|
| 136 | + $persist = $this->config->get( 'resource/'.$name.'/opt-persistent', false ); |
|
| 137 | + |
|
| 138 | + $dsn = $adapter.':dbname='.$dbase; |
|
| 139 | 139 | if( $sock == null ) |
| 140 | 140 | { |
| 141 | - $dsn .= isset( $host ) ? ';host=' . $host : ''; |
|
| 142 | - $dsn .= isset( $port ) ? ';port=' . $port : ''; |
|
| 141 | + $dsn .= isset( $host ) ? ';host='.$host : ''; |
|
| 142 | + $dsn .= isset( $port ) ? ';port='.$port : ''; |
|
| 143 | 143 | } |
| 144 | 144 | else |
| 145 | 145 | { |
| 146 | - $dsn .= ';unix_socket=' . $sock; |
|
| 146 | + $dsn .= ';unix_socket='.$sock; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $params = array( $dsn, $user, $pass, array( \PDO::ATTR_PERSISTENT => $persist ) ); |
| 150 | - $stmts = $this->config->get( 'resource/' . $name . '/stmt', array() ); |
|
| 150 | + $stmts = $this->config->get( 'resource/'.$name.'/stmt', array() ); |
|
| 151 | 151 | |
| 152 | 152 | return new \Aimeos\MW\DB\Connection\PDO( $params, $stmts ); |
| 153 | 153 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $message = json_encode( $message ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if( error_log( '<' . $facility . '> ' . $level . ' ' . $message ) === false ) { |
|
| 74 | + if( error_log( '<'.$facility.'> '.$level.' '.$message ) === false ) { |
|
| 75 | 75 | throw new \Aimeos\MW\Logger\Exception( sprintf( |
| 76 | 76 | 'Unable to log message with priority "%1$d": %2$s', $priority, $message ) ); |
| 77 | 77 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Log messages to a database table. |
| 17 | - * |
|
| 17 | + * |
|
| 18 | 18 | * @package MW |
| 19 | 19 | * @subpackage Logger |
| 20 | 20 | */ |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $this->facilities = $facilities; |
| 46 | 46 | |
| 47 | 47 | if( $requestid === null ) { |
| 48 | - $requestid = md5( php_uname('n') . getmypid() . date( 'Y-m-d H:i:s' ) ); |
|
| 48 | + $requestid = md5( php_uname( 'n' ).getmypid().date( 'Y-m-d H:i:s' ) ); |
|
| 49 | 49 | } |
| 50 | 50 | $this->requestid = $requestid; |
| 51 | 51 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function checkClass( $name, $object ) |
| 31 | 31 | { |
| 32 | - if( ($object instanceof $name) === false ) { |
|
| 32 | + if( ( $object instanceof $name ) === false ) { |
|
| 33 | 33 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Object doesn\'t implement "%1$s"', $name ) ); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public static function checkClassList( $name, array $list ) |
| 46 | 46 | { |
| 47 | 47 | foreach( $list as $object ) { |
| 48 | - if( ($object instanceof $name) === false ) { |
|
| 48 | + if( ( $object instanceof $name ) === false ) { |
|
| 49 | 49 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Object doesn\'t implement "%1$s"', $name ) ); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | foreach( $attributes as $key => $item ) |
| 99 | 99 | { |
| 100 | 100 | if( $item instanceof $iface ) { |
| 101 | - $translations[ $item->getCode() ] = $item->getInternalCode(); |
|
| 101 | + $translations[$item->getCode()] = $item->getInternalCode(); |
|
| 102 | 102 | } else if( isset( $item['code'] ) ) { |
| 103 | - $translations[ $item['code'] ] = $item['internalcode']; |
|
| 103 | + $translations[$item['code']] = $item['internalcode']; |
|
| 104 | 104 | } else { |
| 105 | 105 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
| 106 | 106 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | foreach( $attributes as $key => $item ) |
| 127 | 127 | { |
| 128 | 128 | if( $item instanceof $iface ) { |
| 129 | - $types[ $item->getCode() ] = $item->getInternalType(); |
|
| 129 | + $types[$item->getCode()] = $item->getInternalType(); |
|
| 130 | 130 | } else if( isset( $item['code'] ) ) { |
| 131 | - $types[ $item['code'] ] = $item['internaltype']; |
|
| 131 | + $types[$item['code']] = $item['internaltype']; |
|
| 132 | 132 | } else { |
| 133 | 133 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
| 134 | 134 | } |