@@ -174,7 +174,7 @@ |
||
174 | 174 | * Reconnects to the database server if not in a transaction |
175 | 175 | * |
176 | 176 | * @param \Exception $e Exception to throw if a transaction is running |
177 | - * @return \Aimeos\MW\DB\Statement\Iface Object for method chaining |
|
177 | + * @return Base Object for method chaining |
|
178 | 178 | * @throws \Exception If a transaction is running |
179 | 179 | */ |
180 | 180 | protected function reconnect( \Exception $e ) |
@@ -79,7 +79,7 @@ |
||
79 | 79 | /** |
80 | 80 | * Binds the parameters and executes the SQL statment |
81 | 81 | * |
82 | - * @return \Doctrine\DBAL\Driver\Statement Executed DBAL statement |
|
82 | + * @return \PDOStatement Executed DBAL statement |
|
83 | 83 | */ |
84 | 84 | protected function exec() |
85 | 85 | { |
@@ -65,9 +65,12 @@ |
||
65 | 65 | } |
66 | 66 | catch( \PDOException $e ) |
67 | 67 | { |
68 | - try { |
|
68 | + try |
|
69 | + { |
|
69 | 70 | $stmt = $this->reconnect( $e )->exec(); |
70 | - } catch( \PDOException $e ) { |
|
71 | + } |
|
72 | + catch( \PDOException $e ) |
|
73 | + { |
|
71 | 74 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
72 | 75 | } |
73 | 76 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $message = json_encode( $message ); |
61 | 61 | } |
62 | 62 | |
63 | - $message = '<' . $facility . '> ' . date( 'Y-m-d H:i:s' ) . ' ' . $priority . ' ' . $message . PHP_EOL; |
|
63 | + $message = '<'.$facility.'> '.date( 'Y-m-d H:i:s' ).' '.$priority.' '.$message.PHP_EOL; |
|
64 | 64 | |
65 | 65 | if( file_put_contents( $this->filename, $message, FILE_APPEND ) === false ) { |
66 | 66 | throw new \Aimeos\MW\Logger\Exception( sprintf( 'Unable to write to file "%1$s', $this->filename ) ); |
@@ -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 | } |
@@ -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 | } |
@@ -92,9 +92,12 @@ |
||
92 | 92 | } |
93 | 93 | catch( \PDOException $e ) |
94 | 94 | { |
95 | - try { |
|
95 | + try |
|
96 | + { |
|
96 | 97 | $result = $this->reconnect( $e )->exec(); |
97 | - } catch( \PDOException $e ) { |
|
98 | + } |
|
99 | + catch( \PDOException $e ) |
|
100 | + { |
|
98 | 101 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
99 | 102 | } |
100 | 103 | } |
@@ -91,9 +91,12 @@ |
||
91 | 91 | } |
92 | 92 | catch( \Doctrine\DBAL\DBALException $e ) |
93 | 93 | { |
94 | - try { |
|
94 | + try |
|
95 | + { |
|
95 | 96 | $result = $this->reconnect( $e )->exec(); |
96 | - } catch( \Doctrine\DBAL\DBALException $e ) { |
|
97 | + } |
|
98 | + catch( \Doctrine\DBAL\DBALException $e ) |
|
99 | + { |
|
97 | 100 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
98 | 101 | } |
99 | 102 | } |
@@ -64,9 +64,12 @@ |
||
64 | 64 | } |
65 | 65 | catch( \Doctrine\DBAL\DBALException $e ) |
66 | 66 | { |
67 | - try { |
|
67 | + try |
|
68 | + { |
|
68 | 69 | $stmt = $this->reconnect( $e )->exec(); |
69 | - } catch( \Doctrine\DBAL\DBALException $e ) { |
|
70 | + } |
|
71 | + catch( \Doctrine\DBAL\DBALException $e ) |
|
72 | + { |
|
70 | 73 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
71 | 74 | } |
72 | 75 | } |
@@ -81,15 +81,15 @@ |
||
81 | 81 | $dbase = $this->getConfig( 'db/database', 'aimeos' ); |
82 | 82 | $persist = $this->getConfig( 'db/opt-persistent', false ); |
83 | 83 | |
84 | - $dsn = $adapter . ':dbname=' . $dbase; |
|
84 | + $dsn = $adapter.':dbname='.$dbase; |
|
85 | 85 | if( $sock == null ) |
86 | 86 | { |
87 | - $dsn .= isset( $host ) ? ';host=' . $host : ''; |
|
88 | - $dsn .= isset( $port ) ? ';port=' . $port : ''; |
|
87 | + $dsn .= isset( $host ) ? ';host='.$host : ''; |
|
88 | + $dsn .= isset( $port ) ? ';port='.$port : ''; |
|
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | - $dsn .= ';unix_socket=' . $sock; |
|
92 | + $dsn .= ';unix_socket='.$sock; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $params = array( $dsn, $user, $pass, array( \PDO::ATTR_PERSISTENT => $persist ) ); |