@@ -56,7 +56,7 @@ |
||
56 | 56 | throw new \Aimeos\MW\DB\Exception( sprintf( 'Invalid value "%1$d" for statement type', $type ) ); |
57 | 57 | } |
58 | 58 | } catch( \PDOException $e ) { |
59 | - throw new \Aimeos\MW\DB\Exception($e->getMessage(), $e->getCode(), $e->errorInfo ); |
|
59 | + throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 |
@@ -45,7 +45,8 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function create( $sql, $type = \Aimeos\MW\DB\Connection\Base::TYPE_SIMPLE ) |
47 | 47 | { |
48 | - try { |
|
48 | + try |
|
49 | + { |
|
49 | 50 | switch( $type ) |
50 | 51 | { |
51 | 52 | case \Aimeos\MW\DB\Connection\Base::TYPE_SIMPLE: |
@@ -55,7 +56,9 @@ discard block |
||
55 | 56 | default: |
56 | 57 | throw new \Aimeos\MW\DB\Exception( sprintf( 'Invalid value "%1$d" for statement type', $type ) ); |
57 | 58 | } |
58 | - } catch( \PDOException $e ) { |
|
59 | + } |
|
60 | + catch( \PDOException $e ) |
|
61 | + { |
|
59 | 62 | throw new \Aimeos\MW\DB\Exception($e->getMessage(), $e->getCode(), $e->errorInfo ); |
60 | 63 | } |
61 | 64 | } |
@@ -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. |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | try { |
48 | 48 | $this->stmt->bindValue( $position, $value, $this->getPdoType( $type, $value ) ); |
49 | - } catch ( \PDOException $pe ) { |
|
49 | + } catch( \PDOException $pe ) { |
|
50 | 50 | throw new \Aimeos\MW\DB\Exception( $pe->getMessage(), $pe->getCode(), $pe->errorInfo ); |
51 | 51 | } |
52 | 52 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | try { |
64 | 64 | $this->stmt->execute(); |
65 | - } catch ( \PDOException $pe ) { |
|
65 | + } catch( \PDOException $pe ) { |
|
66 | 66 | throw new \Aimeos\MW\DB\Exception( $pe->getMessage(), $pe->getCode(), $pe->errorInfo ); |
67 | 67 | } |
68 | 68 |
@@ -44,9 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function bind( $position, $value, $type = \Aimeos\MW\DB\Statement\Base::PARAM_STR ) |
46 | 46 | { |
47 | - try { |
|
47 | + try |
|
48 | + { |
|
48 | 49 | $this->stmt->bindValue( $position, $value, $this->getPdoType( $type, $value ) ); |
49 | - } catch ( \PDOException $pe ) { |
|
50 | + } |
|
51 | + catch ( \PDOException $pe ) |
|
52 | + { |
|
50 | 53 | throw new \Aimeos\MW\DB\Exception( $pe->getMessage(), $pe->getCode(), $pe->errorInfo ); |
51 | 54 | } |
52 | 55 | } |
@@ -60,9 +63,12 @@ discard block |
||
60 | 63 | */ |
61 | 64 | public function execute() |
62 | 65 | { |
63 | - try { |
|
66 | + try |
|
67 | + { |
|
64 | 68 | $this->stmt->execute(); |
65 | - } catch ( \PDOException $pe ) { |
|
69 | + } |
|
70 | + catch ( \PDOException $pe ) |
|
71 | + { |
|
66 | 72 | throw new \Aimeos\MW\DB\Exception( $pe->getMessage(), $pe->getCode(), $pe->errorInfo ); |
67 | 73 | } |
68 | 74 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | try { |
47 | 47 | $this->stmt->bindValue( $position, $value, $this->getPdoType( $type, $value ) ); |
48 | - } catch ( \Doctrine\DBAL\DBALException $e ) { |
|
48 | + } catch( \Doctrine\DBAL\DBALException $e ) { |
|
49 | 49 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
50 | 50 | } |
51 | 51 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | try { |
63 | 63 | $this->stmt->execute(); |
64 | - } catch ( \Doctrine\DBAL\DBALException $e ) { |
|
64 | + } catch( \Doctrine\DBAL\DBALException $e ) { |
|
65 | 65 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
66 | 66 | } |
67 | 67 |
@@ -43,9 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function bind( $position, $value, $type = \Aimeos\MW\DB\Statement\Base::PARAM_STR ) |
45 | 45 | { |
46 | - try { |
|
46 | + try |
|
47 | + { |
|
47 | 48 | $this->stmt->bindValue( $position, $value, $this->getPdoType( $type, $value ) ); |
48 | - } catch ( \Doctrine\DBAL\DBALException $e ) { |
|
49 | + } |
|
50 | + catch ( \Doctrine\DBAL\DBALException $e ) |
|
51 | + { |
|
49 | 52 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
50 | 53 | } |
51 | 54 | } |
@@ -59,9 +62,12 @@ discard block |
||
59 | 62 | */ |
60 | 63 | public function execute() |
61 | 64 | { |
62 | - try { |
|
65 | + try |
|
66 | + { |
|
63 | 67 | $this->stmt->execute(); |
64 | - } catch ( \Doctrine\DBAL\DBALException $e ) { |
|
68 | + } |
|
69 | + catch ( \Doctrine\DBAL\DBALException $e ) |
|
70 | + { |
|
65 | 71 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
66 | 72 | } |
67 | 73 |
@@ -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 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | try |
67 | 67 | { |
68 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
68 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
69 | 69 | |
70 | 70 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
71 | 71 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->count[$name] = 0; |
74 | 74 | } |
75 | 75 | |
76 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
76 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
77 | 77 | |
78 | 78 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
79 | 79 | { |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function createConnection( $name, $adapter ) |
121 | 121 | { |
122 | - $params = $this->config->get( 'resource/' . $name ); |
|
122 | + $params = $this->config->get( 'resource/'.$name ); |
|
123 | 123 | |
124 | - $params['user'] = $this->config->get( 'resource/' . $name . '/username' ); |
|
125 | - $params['dbname'] = $this->config->get( 'resource/' . $name . '/database' ); |
|
124 | + $params['user'] = $this->config->get( 'resource/'.$name.'/username' ); |
|
125 | + $params['dbname'] = $this->config->get( 'resource/'.$name.'/database' ); |
|
126 | 126 | |
127 | - if( ( $socket = $this->config->get( 'resource/' . $name . '/socket' ) ) != null ) { |
|
127 | + if( ( $socket = $this->config->get( 'resource/'.$name.'/socket' ) ) != null ) { |
|
128 | 128 | $params['unix_socket'] = $socket; |
129 | 129 | } |
130 | 130 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $conn = \Doctrine\DBAL\DriverManager::getConnection( $params ); |
141 | 141 | $dbc = new \Aimeos\MW\DB\Connection\DBAL( $conn ); |
142 | 142 | |
143 | - foreach( $this->config->get( 'resource/' . $name . '/stmt', [] ) as $stmt ) { |
|
143 | + foreach( $this->config->get( 'resource/'.$name.'/stmt', [] ) as $stmt ) { |
|
144 | 144 | $dbc->create( $stmt )->execute()->finish(); |
145 | 145 | } |
146 | 146 |
@@ -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 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | try |
57 | 57 | { |
58 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
58 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
59 | 59 | |
60 | 60 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
61 | 61 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->count[$name] = 0; |
64 | 64 | } |
65 | 65 | |
66 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
66 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
67 | 67 | |
68 | 68 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
69 | 69 | { |
@@ -109,33 +109,33 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected function createConnection( $name, $adapter ) |
111 | 111 | { |
112 | - $host = $this->config->get( 'resource/' . $name . '/host' ); |
|
113 | - $port = $this->config->get( 'resource/' . $name . '/port' ); |
|
114 | - $user = $this->config->get( 'resource/' . $name . '/username' ); |
|
115 | - $pass = $this->config->get( 'resource/' . $name . '/password' ); |
|
116 | - $sock = $this->config->get( 'resource/' . $name . '/socket' ); |
|
117 | - $dbase = $this->config->get( 'resource/' . $name . '/database' ); |
|
118 | - |
|
119 | - $dsn = $adapter . ':dbname=' . $dbase; |
|
112 | + $host = $this->config->get( 'resource/'.$name.'/host' ); |
|
113 | + $port = $this->config->get( 'resource/'.$name.'/port' ); |
|
114 | + $user = $this->config->get( 'resource/'.$name.'/username' ); |
|
115 | + $pass = $this->config->get( 'resource/'.$name.'/password' ); |
|
116 | + $sock = $this->config->get( 'resource/'.$name.'/socket' ); |
|
117 | + $dbase = $this->config->get( 'resource/'.$name.'/database' ); |
|
118 | + |
|
119 | + $dsn = $adapter.':dbname='.$dbase; |
|
120 | 120 | if( $sock == null ) |
121 | 121 | { |
122 | - $dsn .= isset( $host ) ? ';host=' . $host : ''; |
|
123 | - $dsn .= isset( $port ) ? ';port=' . $port : ''; |
|
122 | + $dsn .= isset( $host ) ? ';host='.$host : ''; |
|
123 | + $dsn .= isset( $port ) ? ';port='.$port : ''; |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | - $dsn .= ';unix_socket=' . $sock; |
|
127 | + $dsn .= ';unix_socket='.$sock; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $attr = array( |
131 | - \PDO::ATTR_PERSISTENT => $this->config->get( 'resource/' . $name . '/opt-persistent', false ), |
|
131 | + \PDO::ATTR_PERSISTENT => $this->config->get( 'resource/'.$name.'/opt-persistent', false ), |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | $pdo = new \PDO( $dsn, $user, $pass, $attr ); |
135 | 135 | $pdo->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION ); |
136 | 136 | $dbc = new \Aimeos\MW\DB\Connection\PDO( $pdo ); |
137 | 137 | |
138 | - foreach( $this->config->get( 'resource/' . $name . '/stmt', [] ) as $stmt ) { |
|
138 | + foreach( $this->config->get( 'resource/'.$name.'/stmt', [] ) as $stmt ) { |
|
139 | 139 | $dbc->create( $stmt )->execute()->finish(); |
140 | 140 | } |
141 | 141 |
@@ -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 | } |