@@ -127,8 +127,6 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * Quotes a table name for use in a query. |
129 | 129 | * @param string $name table name |
130 | - * @param string $lft left delimiter |
|
131 | - * @param string $rgt right delimiter |
|
132 | 130 | * @return string the properly quoted table name |
133 | 131 | */ |
134 | 132 | public function quoteTableName($name) |
@@ -150,8 +148,6 @@ discard block |
||
150 | 148 | /** |
151 | 149 | * Quotes a column name for use in a query. |
152 | 150 | * @param string $name column name |
153 | - * @param string $lft left delimiter |
|
154 | - * @param string $rgt right delimiter |
|
155 | 151 | * @return string the properly quoted column name |
156 | 152 | */ |
157 | 153 | public function quoteColumnName($name) |
@@ -166,8 +162,6 @@ discard block |
||
166 | 162 | /** |
167 | 163 | * Quotes a column alias for use in a query. |
168 | 164 | * @param string $name column alias |
169 | - * @param string $lft left delimiter |
|
170 | - * @param string $rgt right delimiter |
|
171 | 165 | * @return string the properly quoted column alias |
172 | 166 | */ |
173 | 167 | public function quoteColumnAlias($name) |
@@ -179,14 +179,14 @@ |
||
179 | 179 | return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt; |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Returns all table names in the database. |
|
184 | - * This method should be overridden by child classes in order to support this feature |
|
185 | - * because the default implementation simply throws an exception. |
|
186 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
187 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
188 | - * @return array all table names in the database. |
|
189 | - */ |
|
182 | + /** |
|
183 | + * Returns all table names in the database. |
|
184 | + * This method should be overridden by child classes in order to support this feature |
|
185 | + * because the default implementation simply throws an exception. |
|
186 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
187 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
188 | + * @return array all table names in the database. |
|
189 | + */ |
|
190 | 190 | abstract public function findTableNames($schema=''); |
191 | 191 | } |
192 | 192 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | abstract class TDbMetaData extends TComponent |
23 | 23 | { |
24 | - private $_tableInfoCache=array(); |
|
24 | + private $_tableInfoCache = array(); |
|
25 | 25 | private $_connection; |
26 | 26 | |
27 | 27 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct($conn) |
36 | 36 | { |
37 | - $this->_connection=$conn; |
|
37 | + $this->_connection = $conn; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $conn->setActive(true); //must be connected before retrieving driver name |
56 | 56 | $driver = $conn->getDriverName(); |
57 | - switch(strtolower($driver)) |
|
57 | + switch (strtolower($driver)) |
|
58 | 58 | { |
59 | 59 | case 'pgsql': |
60 | 60 | Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData'); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // Prado::using('System.Data.Common.IbmDb2.TIbmDb2MetaData'); |
80 | 80 | // return new TIbmDb2MetaData($conn); |
81 | 81 | default: |
82 | - throw new TDbException('ar_invalid_database_driver',$driver); |
|
82 | + throw new TDbException('ar_invalid_database_driver', $driver); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * @param string table or view name |
89 | 89 | * @return TDbTableInfo table information. |
90 | 90 | */ |
91 | - public function getTableInfo($tableName=null) |
|
91 | + public function getTableInfo($tableName = null) |
|
92 | 92 | { |
93 | - $key = $tableName===null?$this->getDbConnection()->getConnectionString():$tableName; |
|
94 | - if(!isset($this->_tableInfoCache[$key])) |
|
93 | + $key = $tableName === null ? $this->getDbConnection()->getConnectionString() : $tableName; |
|
94 | + if (!isset($this->_tableInfoCache[$key])) |
|
95 | 95 | { |
96 | 96 | $class = $this->getTableInfoClass(); |
97 | - $tableInfo = $tableName===null ? new $class : $this->createTableInfo($tableName); |
|
97 | + $tableInfo = $tableName === null ? new $class : $this->createTableInfo($tableName); |
|
98 | 98 | $this->_tableInfoCache[$key] = $tableInfo; |
99 | 99 | } |
100 | 100 | return $this->_tableInfoCache[$key]; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string table name. |
106 | 106 | * @return TDbCommandBuilder command builder instance for the given table. |
107 | 107 | */ |
108 | - public function createCommandBuilder($tableName=null) |
|
108 | + public function createCommandBuilder($tableName = null) |
|
109 | 109 | { |
110 | 110 | return $this->getTableInfo($tableName)->createCommandBuilder($this->getDbConnection()); |
111 | 111 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | $rgt = $lft = isset($args[1]) ? $args[1] : ''; |
140 | 140 | $rgt = isset($args[2]) ? $args[2] : $rgt; |
141 | 141 | |
142 | - if(strpos($name, '.')===false) |
|
142 | + if (strpos($name, '.') === false) |
|
143 | 143 | return $lft . $name . $rgt; |
144 | - $names=explode('.', $name); |
|
145 | - foreach($names as &$n) |
|
144 | + $names = explode('.', $name); |
|
145 | + foreach ($names as &$n) |
|
146 | 146 | $n = $lft . $n . $rgt; |
147 | 147 | return implode('.', $names); |
148 | 148 | } |
@@ -187,6 +187,6 @@ discard block |
||
187 | 187 | * If not empty, the returned table names will be prefixed with the schema name. |
188 | 188 | * @return array all table names in the database. |
189 | 189 | */ |
190 | - abstract public function findTableNames($schema=''); |
|
190 | + abstract public function findTableNames($schema = ''); |
|
191 | 191 | } |
192 | 192 |
@@ -142,8 +142,9 @@ |
||
142 | 142 | if(strpos($name, '.')===false) |
143 | 143 | return $lft . $name . $rgt; |
144 | 144 | $names=explode('.', $name); |
145 | - foreach($names as &$n) |
|
146 | - $n = $lft . $n . $rgt; |
|
145 | + foreach($names as &$n) { |
|
146 | + $n = $lft . $n . $rgt; |
|
147 | + } |
|
147 | 148 | return implode('.', $names); |
148 | 149 | } |
149 | 150 |
@@ -47,6 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @param TDbConnection database connection. |
50 | + * @param TDbConnection $connection |
|
50 | 51 | * @return TDbCommandBuilder new command builder |
51 | 52 | */ |
52 | 53 | public function createCommandBuilder($connection) |
@@ -58,6 +59,8 @@ discard block |
||
58 | 59 | /** |
59 | 60 | * @param string information array key name |
60 | 61 | * @param mixed default value if information array value is null |
62 | + * @param string $name |
|
63 | + * @param boolean $default |
|
61 | 64 | * @return mixed information array value. |
62 | 65 | */ |
63 | 66 | protected function getInfo($name,$default=null) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class TDbTableInfo extends TComponent |
20 | 20 | { |
21 | - private $_info=array(); |
|
21 | + private $_info = array(); |
|
22 | 22 | |
23 | 23 | private $_primaryKeys; |
24 | 24 | private $_foreignKeys; |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * Sets the database table meta data information. |
38 | 38 | * @param array table column information. |
39 | 39 | */ |
40 | - public function __construct($tableInfo=array(),$primary=array(),$foreign=array()) |
|
40 | + public function __construct($tableInfo = array(), $primary = array(), $foreign = array()) |
|
41 | 41 | { |
42 | - $this->_info=$tableInfo; |
|
43 | - $this->_primaryKeys=$primary; |
|
44 | - $this->_foreignKeys=$foreign; |
|
45 | - $this->_columns=new TMap; |
|
42 | + $this->_info = $tableInfo; |
|
43 | + $this->_primaryKeys = $primary; |
|
44 | + $this->_foreignKeys = $foreign; |
|
45 | + $this->_columns = new TMap; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function createCommandBuilder($connection) |
53 | 53 | { |
54 | 54 | Prado::using('System.Data.Common.TDbCommandBuilder'); |
55 | - return new TDbCommandBuilder($connection,$this); |
|
55 | + return new TDbCommandBuilder($connection, $this); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param mixed default value if information array value is null |
61 | 61 | * @return mixed information array value. |
62 | 62 | */ |
63 | - protected function getInfo($name,$default=null) |
|
63 | + protected function getInfo($name, $default = null) |
|
64 | 64 | { |
65 | 65 | return isset($this->_info[$name]) ? $this->_info[$name] : $default; |
66 | 66 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param string information array key name |
70 | 70 | * @param mixed new information array value. |
71 | 71 | */ |
72 | - protected function setInfo($name,$value) |
|
72 | + protected function setInfo($name, $value) |
|
73 | 73 | { |
74 | - $this->_info[$name]=$value; |
|
74 | + $this->_info[$name] = $value; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getIsView() |
97 | 97 | { |
98 | - return $this->getInfo('IsView',false); |
|
98 | + return $this->getInfo('IsView', false); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getColumn($name) |
114 | 114 | { |
115 | - if(($column = $this->_columns->itemAt($name))!==null) |
|
115 | + if (($column = $this->_columns->itemAt($name)) !== null) |
|
116 | 116 | return $column; |
117 | 117 | throw new TDbException('dbtableinfo_invalid_column_name', $name, $this->getTableFullName()); |
118 | 118 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function getColumnNames() |
125 | 125 | { |
126 | - if($this->_names===null) |
|
126 | + if ($this->_names === null) |
|
127 | 127 | { |
128 | - $this->_names=array(); |
|
129 | - foreach($this->getColumns() as $column) |
|
128 | + $this->_names = array(); |
|
129 | + foreach ($this->getColumns() as $column) |
|
130 | 130 | $this->_names[] = $column->getColumnName(); |
131 | 131 | } |
132 | 132 | return $this->_names; |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getLowerCaseColumnNames() |
155 | 155 | { |
156 | - if($this->_lowercase===null) |
|
156 | + if ($this->_lowercase === null) |
|
157 | 157 | { |
158 | - $this->_lowercase=array(); |
|
159 | - foreach($this->getColumns()->getKeys() as $key) |
|
158 | + $this->_lowercase = array(); |
|
159 | + foreach ($this->getColumns()->getKeys() as $key) |
|
160 | 160 | $this->_lowercase[strtolower($key)] = $key; |
161 | 161 | } |
162 | 162 | return $this->_lowercase; |
@@ -126,8 +126,9 @@ discard block |
||
126 | 126 | if($this->_names===null) |
127 | 127 | { |
128 | 128 | $this->_names=array(); |
129 | - foreach($this->getColumns() as $column) |
|
130 | - $this->_names[] = $column->getColumnName(); |
|
129 | + foreach($this->getColumns() as $column) { |
|
130 | + $this->_names[] = $column->getColumnName(); |
|
131 | + } |
|
131 | 132 | } |
132 | 133 | return $this->_names; |
133 | 134 | } |
@@ -156,8 +157,9 @@ discard block |
||
156 | 157 | if($this->_lowercase===null) |
157 | 158 | { |
158 | 159 | $this->_lowercase=array(); |
159 | - foreach($this->getColumns()->getKeys() as $key) |
|
160 | - $this->_lowercase[strtolower($key)] = $key; |
|
160 | + foreach($this->getColumns()->getKeys() as $key) { |
|
161 | + $this->_lowercase[strtolower($key)] = $key; |
|
162 | + } |
|
161 | 163 | } |
162 | 164 | return $this->_lowercase; |
163 | 165 | } |
@@ -89,6 +89,7 @@ discard block |
||
89 | 89 | * Updates the table with new data. |
90 | 90 | * @param array date for update. |
91 | 91 | * @param TSqlCriteria update conditions and parameters. |
92 | + * @param TSqlCriteria $criteria |
|
92 | 93 | * @return integer number of records affected. |
93 | 94 | */ |
94 | 95 | public function update($data, $criteria) |
@@ -207,6 +208,9 @@ discard block |
||
207 | 208 | return $this->onExecuteCommand($command,$command->execute()); |
208 | 209 | } |
209 | 210 | |
211 | + /** |
|
212 | + * @param TDbTableInfo $table |
|
213 | + */ |
|
210 | 214 | public function getIndexKeyCondition($table,$fields,$values) |
211 | 215 | { |
212 | 216 | if (!count($values)) |
@@ -351,7 +355,7 @@ discard block |
||
351 | 355 | * Inserts a new record into the table. Each array key must |
352 | 356 | * correspond to a column name in the table unless a null value is permitted. |
353 | 357 | * @param array new record data. |
354 | - * @return mixed last insert id if one column contains a serial or sequence, |
|
358 | + * @return string|boolean last insert id if one column contains a serial or sequence, |
|
355 | 359 | * otherwise true if command executes successfully and affected 1 or more rows. |
356 | 360 | */ |
357 | 361 | public function insert($data) |
@@ -370,7 +374,7 @@ discard block |
||
370 | 374 | /** |
371 | 375 | * Iterate through all the columns and returns the last insert id of the |
372 | 376 | * first column that has a sequence or serial. |
373 | - * @return mixed last insert id, null if none is found. |
|
377 | + * @return string|null last insert id, null if none is found. |
|
374 | 378 | */ |
375 | 379 | public function getLastInsertID() |
376 | 380 | { |
@@ -381,6 +385,7 @@ discard block |
||
381 | 385 | * @param string __call method name |
382 | 386 | * @param string criteria conditions |
383 | 387 | * @param array method arguments |
388 | + * @param string $condition |
|
384 | 389 | * @return TActiveRecordCriteria criteria created from the method name and its arguments. |
385 | 390 | */ |
386 | 391 | public function createCriteriaFromString($method, $condition, $args) |
@@ -434,6 +439,7 @@ discard block |
||
434 | 439 | * inspected to obtain the sql query to be executed. |
435 | 440 | * @param TDataGatewayCommand originator $sender |
436 | 441 | * @param TDataGatewayEventParameter |
442 | + * @param TDbCommand $command |
|
437 | 443 | */ |
438 | 444 | public function onCreateCommand($command, $criteria) |
439 | 445 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $where = $criteria->getCondition(); |
81 | 81 | $parameters = $criteria->getParameters()->toArray(); |
82 | 82 | $command = $this->getBuilder()->createDeleteCommand($where, $parameters); |
83 | - $this->onCreateCommand($command,$criteria); |
|
83 | + $this->onCreateCommand($command, $criteria); |
|
84 | 84 | $command->prepare(); |
85 | 85 | return $command->execute(); |
86 | 86 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | { |
96 | 96 | $where = $criteria->getCondition(); |
97 | 97 | $parameters = $criteria->getParameters()->toArray(); |
98 | - $command = $this->getBuilder()->createUpdateCommand($data,$where, $parameters); |
|
99 | - $this->onCreateCommand($command,$criteria); |
|
98 | + $command = $this->getBuilder()->createUpdateCommand($data, $where, $parameters); |
|
99 | + $this->onCreateCommand($command, $criteria); |
|
100 | 100 | $command->prepare(); |
101 | 101 | return $this->onExecuteCommand($command, $command->execute()); |
102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function updateByPk($data, $keys) |
110 | 110 | { |
111 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
111 | + list($where, $parameters) = $this->getPrimaryKeyCondition((array) $keys); |
|
112 | 112 | return $this->update($data, new TSqlCriteria($where, $parameters)); |
113 | 113 | } |
114 | 114 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function getFindCommand($criteria) |
143 | 143 | { |
144 | - if($criteria===null) |
|
144 | + if ($criteria === null) |
|
145 | 145 | return $this->getBuilder()->createFindCommand(); |
146 | 146 | $where = $criteria->getCondition(); |
147 | 147 | $parameters = $criteria->getParameters()->toArray(); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $limit = $criteria->getLimit(); |
150 | 150 | $offset = $criteria->getOffset(); |
151 | 151 | $select = $criteria->getSelect(); |
152 | - $command = $this->getBuilder()->createFindCommand($where,$parameters,$ordering,$limit,$offset,$select); |
|
152 | + $command = $this->getBuilder()->createFindCommand($where, $parameters, $ordering, $limit, $offset, $select); |
|
153 | 153 | $this->onCreateCommand($command, $criteria); |
154 | 154 | return $command; |
155 | 155 | } |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function findByPk($keys) |
162 | 162 | { |
163 | - if($keys===null) |
|
163 | + if ($keys === null) |
|
164 | 164 | return null; |
165 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
165 | + list($where, $parameters) = $this->getPrimaryKeyCondition((array) $keys); |
|
166 | 166 | $command = $this->getBuilder()->createFindCommand($where, $parameters); |
167 | - $this->onCreateCommand($command, new TSqlCriteria($where,$parameters)); |
|
167 | + $this->onCreateCommand($command, new TSqlCriteria($where, $parameters)); |
|
168 | 168 | return $this->onExecuteCommand($command, $command->queryRow()); |
169 | 169 | } |
170 | 170 | |
@@ -174,22 +174,22 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function findAllByPk($keys) |
176 | 176 | { |
177 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
177 | + $where = $this->getCompositeKeyCondition((array) $keys); |
|
178 | 178 | $command = $this->getBuilder()->createFindCommand($where); |
179 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
180 | - return $this->onExecuteCommand($command,$command->query()); |
|
179 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
180 | + return $this->onExecuteCommand($command, $command->query()); |
|
181 | 181 | } |
182 | 182 | |
183 | - public function findAllByIndex($criteria,$fields,$values) |
|
183 | + public function findAllByIndex($criteria, $fields, $values) |
|
184 | 184 | { |
185 | - $index = $this->getIndexKeyCondition($this->getTableInfo(),$fields,$values); |
|
186 | - if(strlen($where = $criteria->getCondition())>0) |
|
185 | + $index = $this->getIndexKeyCondition($this->getTableInfo(), $fields, $values); |
|
186 | + if (strlen($where = $criteria->getCondition()) > 0) |
|
187 | 187 | $criteria->setCondition("({$index}) AND ({$where})"); |
188 | 188 | else |
189 | 189 | $criteria->setCondition($index); |
190 | 190 | $command = $this->getFindCommand($criteria); |
191 | 191 | $this->onCreateCommand($command, $criteria); |
192 | - return $this->onExecuteCommand($command,$command->query()); |
|
192 | + return $this->onExecuteCommand($command, $command->query()); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function deleteByPk($keys) |
200 | 200 | { |
201 | - if(count($keys)==0) |
|
201 | + if (count($keys) == 0) |
|
202 | 202 | return 0; |
203 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
203 | + $where = $this->getCompositeKeyCondition((array) $keys); |
|
204 | 204 | $command = $this->getBuilder()->createDeleteCommand($where); |
205 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
205 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
206 | 206 | $command->prepare(); |
207 | - return $this->onExecuteCommand($command,$command->execute()); |
|
207 | + return $this->onExecuteCommand($command, $command->execute()); |
|
208 | 208 | } |
209 | 209 | |
210 | - public function getIndexKeyCondition($table,$fields,$values) |
|
210 | + public function getIndexKeyCondition($table, $fields, $values) |
|
211 | 211 | { |
212 | 212 | if (!count($values)) |
213 | 213 | return 'FALSE'; |
214 | 214 | $columns = array(); |
215 | 215 | $tableName = $table->getTableFullName(); |
216 | - foreach($fields as $field) |
|
217 | - $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
218 | - return '('.implode(', ',$columns).') IN '.$this->quoteTuple($values); |
|
216 | + foreach ($fields as $field) |
|
217 | + $columns[] = $tableName . '.' . $table->getColumn($field)->getColumnName(); |
|
218 | + return '(' . implode(', ', $columns) . ') IN ' . $this->quoteTuple($values); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | { |
228 | 228 | $primary = $this->getTableInfo()->getPrimaryKeys(); |
229 | 229 | $count = count($primary); |
230 | - if($count===0) |
|
230 | + if ($count === 0) |
|
231 | 231 | { |
232 | 232 | throw new TDbException('dbtablegateway_no_primary_key_found', |
233 | 233 | $this->getTableInfo()->getTableFullName()); |
234 | 234 | } |
235 | - if(!is_array($values) || count($values) === 0) |
|
235 | + if (!is_array($values) || count($values) === 0) |
|
236 | 236 | { |
237 | 237 | throw new TDbException('dbtablegateway_missing_pk_values', |
238 | 238 | $this->getTableInfo()->getTableFullName()); |
239 | 239 | } |
240 | - if($count>1 && (!isset($values[0]) || !is_array($values[0]))) |
|
240 | + if ($count > 1 && (!isset($values[0]) || !is_array($values[0]))) |
|
241 | 241 | $values = array($values); |
242 | - if($count > 1 && count($values[0]) !== $count) |
|
242 | + if ($count > 1 && count($values[0]) !== $count) |
|
243 | 243 | { |
244 | 244 | throw new TDbException('dbtablegateway_pk_value_count_mismatch', |
245 | 245 | $this->getTableInfo()->getTableFullName()); |
246 | 246 | } |
247 | - return $this->getIndexKeyCondition($this->getTableInfo(),$primary, $values); |
|
247 | + return $this->getIndexKeyCondition($this->getTableInfo(), $primary, $values); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | { |
257 | 257 | $conn = $this->getDbConnection(); |
258 | 258 | $data = array(); |
259 | - foreach($array as $k=>$v) |
|
259 | + foreach ($array as $k=>$v) |
|
260 | 260 | $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
261 | - return '('.implode(', ', $data).')'; |
|
261 | + return '(' . implode(', ', $data) . ')'; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -269,19 +269,19 @@ discard block |
||
269 | 269 | protected function getPrimaryKeyCondition($values) |
270 | 270 | { |
271 | 271 | $primary = $this->getTableInfo()->getPrimaryKeys(); |
272 | - if(count($primary)===0) |
|
272 | + if (count($primary) === 0) |
|
273 | 273 | { |
274 | 274 | throw new TDbException('dbtablegateway_no_primary_key_found', |
275 | 275 | $this->getTableInfo()->getTableFullName()); |
276 | 276 | } |
277 | - $criteria=array(); |
|
278 | - $bindings=array(); |
|
277 | + $criteria = array(); |
|
278 | + $bindings = array(); |
|
279 | 279 | $i = 0; |
280 | - foreach($primary as $key) |
|
280 | + foreach ($primary as $key) |
|
281 | 281 | { |
282 | 282 | $column = $this->getTableInfo()->getColumn($key)->getColumnName(); |
283 | - $criteria[] = $column.' = :'.$key; |
|
284 | - $bindings[$key] = isset($values[$key])?$values[$key]:$values[$i++]; |
|
283 | + $criteria[] = $column . ' = :' . $key; |
|
284 | + $bindings[$key] = isset($values[$key]) ? $values[$key] : $values[$i++]; |
|
285 | 285 | } |
286 | 286 | return array(implode(' AND ', $criteria), $bindings); |
287 | 287 | } |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | $ordering = $criteria->getOrdersBy(); |
320 | 320 | $limit = $criteria->getLimit(); |
321 | 321 | $offset = $criteria->getOffset(); |
322 | - if(count($ordering) > 0) |
|
322 | + if (count($ordering) > 0) |
|
323 | 323 | $sql = $this->getBuilder()->applyOrdering($sql, $ordering); |
324 | - if($limit>=0 || $offset>=0) |
|
324 | + if ($limit >= 0 || $offset >= 0) |
|
325 | 325 | $sql = $this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
326 | 326 | $command = $this->getBuilder()->createCommand($sql); |
327 | 327 | $this->getBuilder()->bindArrayValues($command, $criteria->getParameters()->toArray()); |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function count($criteria) |
337 | 337 | { |
338 | - if($criteria===null) |
|
339 | - return (int)$this->getBuilder()->createCountCommand()->queryScalar(); |
|
338 | + if ($criteria === null) |
|
339 | + return (int) $this->getBuilder()->createCountCommand()->queryScalar(); |
|
340 | 340 | $where = $criteria->getCondition(); |
341 | 341 | $parameters = $criteria->getParameters()->toArray(); |
342 | 342 | $ordering = $criteria->getOrdersBy(); |
343 | 343 | $limit = $criteria->getLimit(); |
344 | 344 | $offset = $criteria->getOffset(); |
345 | - $command = $this->getBuilder()->createCountCommand($where,$parameters,$ordering,$limit,$offset); |
|
345 | + $command = $this->getBuilder()->createCountCommand($where, $parameters, $ordering, $limit, $offset); |
|
346 | 346 | $this->onCreateCommand($command, $criteria); |
347 | - return $this->onExecuteCommand($command, (int)$command->queryScalar()); |
|
347 | + return $this->onExecuteCommand($command, (int) $command->queryScalar()); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function insert($data) |
358 | 358 | { |
359 | - $command=$this->getBuilder()->createInsertCommand($data); |
|
360 | - $this->onCreateCommand($command, new TSqlCriteria(null,$data)); |
|
359 | + $command = $this->getBuilder()->createInsertCommand($data); |
|
360 | + $this->onCreateCommand($command, new TSqlCriteria(null, $data)); |
|
361 | 361 | $command->prepare(); |
362 | - if($this->onExecuteCommand($command, $command->execute()) > 0) |
|
362 | + if ($this->onExecuteCommand($command, $command->execute()) > 0) |
|
363 | 363 | { |
364 | 364 | $value = $this->getLastInsertId(); |
365 | 365 | return $value !== null ? $value : true; |
@@ -386,13 +386,13 @@ discard block |
||
386 | 386 | public function createCriteriaFromString($method, $condition, $args) |
387 | 387 | { |
388 | 388 | $fields = $this->extractMatchingConditions($method, $condition); |
389 | - $args=count($args) === 1 && is_array($args[0]) ? $args[0] : $args; |
|
390 | - if(count($fields)>count($args)) |
|
389 | + $args = count($args) === 1 && is_array($args[0]) ? $args[0] : $args; |
|
390 | + if (count($fields) > count($args)) |
|
391 | 391 | { |
392 | 392 | throw new TDbException('dbtablegateway_mismatch_args_exception', |
393 | - $method,count($fields),count($args)); |
|
393 | + $method, count($fields), count($args)); |
|
394 | 394 | } |
395 | - return new TSqlCriteria(implode(' ',$fields), $args); |
|
395 | + return new TSqlCriteria(implode(' ', $fields), $args); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -406,21 +406,21 @@ discard block |
||
406 | 406 | { |
407 | 407 | $table = $this->getTableInfo(); |
408 | 408 | $columns = $table->getLowerCaseColumnNames(); |
409 | - $regexp = '/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
409 | + $regexp = '/(' . implode('|', array_keys($columns)) . ')(and|_and_|or|_or_)?/i'; |
|
410 | 410 | $matches = array(); |
411 | - if(!preg_match_all($regexp, strtolower($condition), $matches,PREG_SET_ORDER)) |
|
411 | + if (!preg_match_all($regexp, strtolower($condition), $matches, PREG_SET_ORDER)) |
|
412 | 412 | { |
413 | 413 | throw new TDbException('dbtablegateway_mismatch_column_name', |
414 | 414 | $method, implode(', ', $columns), $table->getTableFullName()); |
415 | 415 | } |
416 | 416 | |
417 | 417 | $fields = array(); |
418 | - foreach($matches as $match) |
|
418 | + foreach ($matches as $match) |
|
419 | 419 | { |
420 | 420 | $key = $columns[$match[1]]; |
421 | 421 | $column = $table->getColumn($key)->getColumnName(); |
422 | 422 | $sql = $column . ' = ? '; |
423 | - if(count($match) > 2) |
|
423 | + if (count($match) > 2) |
|
424 | 424 | $sql .= strtoupper(str_replace('_', '', $match[2])); |
425 | 425 | $fields[] = $sql; |
426 | 426 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | */ |
438 | 438 | public function onCreateCommand($command, $criteria) |
439 | 439 | { |
440 | - $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command,$criteria)); |
|
440 | + $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command, $criteria)); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -471,10 +471,10 @@ discard block |
||
471 | 471 | private $_command; |
472 | 472 | private $_criteria; |
473 | 473 | |
474 | - public function __construct($command,$criteria) |
|
474 | + public function __construct($command, $criteria) |
|
475 | 475 | { |
476 | - $this->_command=$command; |
|
477 | - $this->_criteria=$criteria; |
|
476 | + $this->_command = $command; |
|
477 | + $this->_criteria = $criteria; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | private $_command; |
512 | 512 | private $_result; |
513 | 513 | |
514 | - public function __construct($command,$result) |
|
514 | + public function __construct($command, $result) |
|
515 | 515 | { |
516 | - $this->_command=$command; |
|
517 | - $this->_result=$result; |
|
516 | + $this->_command = $command; |
|
517 | + $this->_result = $result; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function setResult($value) |
540 | 540 | { |
541 | - $this->_result=$value; |
|
541 | + $this->_result = $value; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 |
@@ -213,8 +213,9 @@ discard block |
||
213 | 213 | return 'FALSE'; |
214 | 214 | $columns = array(); |
215 | 215 | $tableName = $table->getTableFullName(); |
216 | - foreach($fields as $field) |
|
217 | - $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
216 | + foreach($fields as $field) { |
|
217 | + $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
218 | + } |
|
218 | 219 | return '('.implode(', ',$columns).') IN '.$this->quoteTuple($values); |
219 | 220 | } |
220 | 221 | |
@@ -256,8 +257,9 @@ discard block |
||
256 | 257 | { |
257 | 258 | $conn = $this->getDbConnection(); |
258 | 259 | $data = array(); |
259 | - foreach($array as $k=>$v) |
|
260 | - $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
260 | + foreach($array as $k=>$v) { |
|
261 | + $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
262 | + } |
|
261 | 263 | return '('.implode(', ', $data).')'; |
262 | 264 | } |
263 | 265 |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | - * @return boolean true if the parameter index are string base, false otherwise. |
|
191 | + * @return boolean|null true if the parameter index are string base, false otherwise. |
|
192 | 192 | */ |
193 | 193 | public function getIsNamedParameters() |
194 | 194 | { |
@@ -206,6 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | /** |
208 | 208 | * @param mixed ordering clause. |
209 | + * @param string $value |
|
209 | 210 | */ |
210 | 211 | public function setOrdersBy($value) |
211 | 212 | { |
@@ -250,6 +251,7 @@ discard block |
||
250 | 251 | |
251 | 252 | /** |
252 | 253 | * @param int record offset. |
254 | + * @param double $value |
|
253 | 255 | */ |
254 | 256 | public function setOffset($value) |
255 | 257 | { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @var mixed |
34 | 34 | * @since 3.1.7 |
35 | 35 | */ |
36 | - private $_select='*'; |
|
36 | + private $_select = '*'; |
|
37 | 37 | private $_condition; |
38 | 38 | private $_parameters; |
39 | 39 | private $_ordersBy; |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @param string sql string after the WHERE stanza |
46 | 46 | * @param mixed named or indexed parameters, accepts as multiple arguments. |
47 | 47 | */ |
48 | - public function __construct($condition=null, $parameters=array()) |
|
48 | + public function __construct($condition = null, $parameters = array()) |
|
49 | 49 | { |
50 | - if(!is_array($parameters) && func_num_args() > 1) |
|
51 | - $parameters = array_slice(func_get_args(),1); |
|
52 | - $this->_parameters=new TAttributeCollection; |
|
50 | + if (!is_array($parameters) && func_num_args() > 1) |
|
51 | + $parameters = array_slice(func_get_args(), 1); |
|
52 | + $this->_parameters = new TAttributeCollection; |
|
53 | 53 | $this->_parameters->setCaseSensitive(true); |
54 | - $this->_parameters->copyFrom((array)$parameters); |
|
55 | - $this->_ordersBy=new TAttributeCollection; |
|
54 | + $this->_parameters->copyFrom((array) $parameters); |
|
55 | + $this->_ordersBy = new TAttributeCollection; |
|
56 | 56 | $this->_ordersBy->setCaseSensitive(true); |
57 | 57 | |
58 | 58 | $this->setCondition($condition); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function setCondition($value) |
128 | 128 | { |
129 | - if(empty($value)) { |
|
129 | + if (empty($value)) { |
|
130 | 130 | // reset the condition |
131 | 131 | $this->_condition = null; |
132 | 132 | return; |
@@ -138,32 +138,32 @@ discard block |
||
138 | 138 | // [LIMIT {[offset,] row_count | row_count OFFSET offset}] |
139 | 139 | // See: http://dev.mysql.com/doc/refman/5.0/en/select.html |
140 | 140 | |
141 | - if(preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) { |
|
141 | + if (preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) { |
|
142 | 142 | // condition contains ORDER BY |
143 | 143 | $value = str_replace($matches[0], '', $value); |
144 | - if(strlen($matches[1]) > 0) { |
|
144 | + if (strlen($matches[1]) > 0) { |
|
145 | 145 | $this->setOrdersBy($matches[1]); |
146 | - } else if(strlen($matches[2]) > 0) { |
|
146 | + } else if (strlen($matches[2]) > 0) { |
|
147 | 147 | $this->setOrdersBy($matches[2]); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if(preg_match('/LIMIT\s+([\d\s,]+)/i', $value, $matches) > 0) { |
|
151 | + if (preg_match('/LIMIT\s+([\d\s,]+)/i', $value, $matches) > 0) { |
|
152 | 152 | // condition contains limit |
153 | 153 | $value = str_replace($matches[0], '', $value); // remove limit from query |
154 | - if(strpos($matches[1], ',')) { // both offset and limit given |
|
154 | + if (strpos($matches[1], ',')) { // both offset and limit given |
|
155 | 155 | list($offset, $limit) = explode(',', $matches[1]); |
156 | - $this->_limit = (int)$limit; |
|
157 | - $this->_offset = (int)$offset; |
|
156 | + $this->_limit = (int) $limit; |
|
157 | + $this->_offset = (int) $offset; |
|
158 | 158 | } else { // only limit given |
159 | - $this->_limit = (int)$matches[1]; |
|
159 | + $this->_limit = (int) $matches[1]; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if(preg_match('/OFFSET\s+(\d+)/i', $value, $matches) > 0) { |
|
163 | + if (preg_match('/OFFSET\s+(\d+)/i', $value, $matches) > 0) { |
|
164 | 164 | // condition contains offset |
165 | 165 | $value = str_replace($matches[0], '', $value); // remove offset from query |
166 | - $this->_offset = (int)$matches[1]; // set offset in criteria |
|
166 | + $this->_offset = (int) $matches[1]; // set offset in criteria |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $this->_condition = trim($value); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function setParameters($value) |
184 | 184 | { |
185 | - if(!(is_array($value) || $value instanceof ArrayAccess)) |
|
185 | + if (!(is_array($value) || $value instanceof ArrayAccess)) |
|
186 | 186 | throw new TException('value must be array or ArrayAccess'); |
187 | 187 | $this->_parameters->copyFrom($value); |
188 | 188 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getIsNamedParameters() |
194 | 194 | { |
195 | - foreach($this->getParameters() as $k=>$v) |
|
195 | + foreach ($this->getParameters() as $k=>$v) |
|
196 | 196 | return is_string($k); |
197 | 197 | } |
198 | 198 | |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function setOrdersBy($value) |
211 | 211 | { |
212 | - if(is_array($value) || $value instanceof Traversable) |
|
212 | + if (is_array($value) || $value instanceof Traversable) |
|
213 | 213 | $this->_ordersBy->copyFrom($value); |
214 | 214 | else |
215 | 215 | { |
216 | - $value=trim(preg_replace('/\s+/',' ',(string)$value)); |
|
217 | - $orderBys=array(); |
|
218 | - foreach(explode(',',$value) as $orderBy) |
|
216 | + $value = trim(preg_replace('/\s+/', ' ', (string) $value)); |
|
217 | + $orderBys = array(); |
|
218 | + foreach (explode(',', $value) as $orderBy) |
|
219 | 219 | { |
220 | - $vs=explode(' ',trim($orderBy)); |
|
221 | - $orderBys[$vs[0]]=isset($vs[1])?$vs[1]:'asc'; |
|
220 | + $vs = explode(' ', trim($orderBy)); |
|
221 | + $orderBys[$vs[0]] = isset($vs[1]) ? $vs[1] : 'asc'; |
|
222 | 222 | } |
223 | 223 | $this->_ordersBy->copyFrom($orderBys); |
224 | 224 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setLimit($value) |
239 | 239 | { |
240 | - $this->_limit=$value; |
|
240 | + $this->_limit = $value; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function setOffset($value) |
255 | 255 | { |
256 | - $this->_offset=$value; |
|
256 | + $this->_offset = $value; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | public function __toString() |
263 | 263 | { |
264 | 264 | $str = ''; |
265 | - if(strlen((string)$this->getCondition()) > 0) |
|
266 | - $str .= '"'.(string)$this->getCondition().'"'; |
|
265 | + if (strlen((string) $this->getCondition()) > 0) |
|
266 | + $str .= '"' . (string) $this->getCondition() . '"'; |
|
267 | 267 | $params = array(); |
268 | - foreach($this->getParameters() as $k=>$v) |
|
268 | + foreach ($this->getParameters() as $k=>$v) |
|
269 | 269 | $params[] = "{$k} => ${v}"; |
270 | - if(count($params) > 0) |
|
271 | - $str .= ', "'.implode(', ',$params).'"'; |
|
270 | + if (count($params) > 0) |
|
271 | + $str .= ', "' . implode(', ', $params) . '"'; |
|
272 | 272 | $orders = array(); |
273 | - foreach($this->getOrdersBy() as $k=>$v) |
|
273 | + foreach ($this->getOrdersBy() as $k=>$v) |
|
274 | 274 | $orders[] = "{$k} => ${v}"; |
275 | - if(count($orders) > 0) |
|
276 | - $str .= ', "'.implode(', ',$orders).'"'; |
|
277 | - if($this->_limit !==null) |
|
278 | - $str .= ', '.$this->_limit; |
|
279 | - if($this->_offset !== null) |
|
280 | - $str .= ', '.$this->_offset; |
|
275 | + if (count($orders) > 0) |
|
276 | + $str .= ', "' . implode(', ', $orders) . '"'; |
|
277 | + if ($this->_limit !== null) |
|
278 | + $str .= ', ' . $this->_limit; |
|
279 | + if ($this->_offset !== null) |
|
280 | + $str .= ', ' . $this->_offset; |
|
281 | 281 | return $str; |
282 | 282 | } |
283 | 283 | } |
@@ -192,8 +192,9 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getIsNamedParameters() |
194 | 194 | { |
195 | - foreach($this->getParameters() as $k=>$v) |
|
196 | - return is_string($k); |
|
195 | + foreach($this->getParameters() as $k=>$v) { |
|
196 | + return is_string($k); |
|
197 | + } |
|
197 | 198 | } |
198 | 199 | |
199 | 200 | /** |
@@ -265,13 +266,15 @@ discard block |
||
265 | 266 | if(strlen((string)$this->getCondition()) > 0) |
266 | 267 | $str .= '"'.(string)$this->getCondition().'"'; |
267 | 268 | $params = array(); |
268 | - foreach($this->getParameters() as $k=>$v) |
|
269 | - $params[] = "{$k} => ${v}"; |
|
269 | + foreach($this->getParameters() as $k=>$v) { |
|
270 | + $params[] = "{$k} => ${v}"; |
|
271 | + } |
|
270 | 272 | if(count($params) > 0) |
271 | 273 | $str .= ', "'.implode(', ',$params).'"'; |
272 | 274 | $orders = array(); |
273 | - foreach($this->getOrdersBy() as $k=>$v) |
|
274 | - $orders[] = "{$k} => ${v}"; |
|
275 | + foreach($this->getOrdersBy() as $k=>$v) { |
|
276 | + $orders[] = "{$k} => ${v}"; |
|
277 | + } |
|
275 | 278 | if(count($orders) > 0) |
276 | 279 | $str .= ', "'.implode(', ',$orders).'"'; |
277 | 280 | if($this->_limit !==null) |
@@ -132,6 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @param TSubMap add new sub mapping. |
135 | + * @param TSubMap $subMap |
|
135 | 136 | */ |
136 | 137 | public function addSubMap($subMap) |
137 | 138 | { |
@@ -140,6 +141,7 @@ discard block |
||
140 | 141 | |
141 | 142 | /** |
142 | 143 | * @param string database value |
144 | + * @param string $value |
|
143 | 145 | * @return TResultMap result mapping. |
144 | 146 | */ |
145 | 147 | public function getSubMap($value) |
@@ -151,6 +153,7 @@ discard block |
||
151 | 153 | /** |
152 | 154 | * Copies the discriminator properties to a new TResultProperty. |
153 | 155 | * @param TResultMap result map holding the discriminator. |
156 | + * @param TResultMap $resultMap |
|
154 | 157 | */ |
155 | 158 | public function initMapping($resultMap) |
156 | 159 | { |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | { |
28 | 28 | private $_column; |
29 | 29 | private $_type; |
30 | - private $_typeHandler=null; |
|
30 | + private $_typeHandler = null; |
|
31 | 31 | private $_columnIndex; |
32 | 32 | private $_nullValue; |
33 | 33 | private $_mapping; |
34 | - private $_resultMaps=array(); |
|
35 | - private $_subMaps=array(); |
|
34 | + private $_resultMaps = array(); |
|
35 | + private $_subMaps = array(); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @return string the name of the column in the result set from which the |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function getSubMap($value) |
146 | 146 | { |
147 | - if(isset($this->_resultMaps[$value])) |
|
147 | + if (isset($this->_resultMaps[$value])) |
|
148 | 148 | return $this->_resultMaps[$value]; |
149 | 149 | } |
150 | 150 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function initialize($manager) |
170 | 170 | { |
171 | - foreach($this->_subMaps as $subMap) |
|
171 | + foreach ($this->_subMaps as $subMap) |
|
172 | 172 | { |
173 | 173 | $this->_resultMaps[$subMap->getValue()] = |
174 | 174 | $manager->getResultMap($subMap->getResultMapping()); |
@@ -55,6 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param string a unique identifier for the <parameterMap>. |
58 | + * @param string $value |
|
58 | 59 | */ |
59 | 60 | public function setID($value) |
60 | 61 | { |
@@ -62,7 +63,7 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | /** |
65 | - * @return TParameterProperty[] list of properties for the parameter map. |
|
66 | + * @return TList list of properties for the parameter map. |
|
66 | 67 | */ |
67 | 68 | public function getProperties() |
68 | 69 | { |
@@ -112,6 +113,7 @@ discard block |
||
112 | 113 | /** |
113 | 114 | * @param int parameter property index |
114 | 115 | * @param TParameterProperty new parameter property. |
116 | + * @param integer $index |
|
115 | 117 | */ |
116 | 118 | public function insertProperty($index, TParameterProperty $property) |
117 | 119 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setID($value) |
60 | 60 | { |
61 | - $this->_ID=$value; |
|
61 | + $this->_ID = $value; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getProperty($index) |
94 | 94 | { |
95 | - if(is_string($index)) |
|
95 | + if (is_string($index)) |
|
96 | 96 | return $this->_propertyMap->itemAt($index); |
97 | - else if(is_int($index)) |
|
97 | + else if (is_int($index)) |
|
98 | 98 | return $this->_properties->itemAt($index); |
99 | 99 | else |
100 | 100 | throw new TSqlMapException('sqlmap_index_must_be_string_or_int', $index); |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function getPropertyValue($registry, $property, $parameterValue) |
138 | 138 | { |
139 | - $value = $this->getObjectValue($parameterValue,$property); |
|
139 | + $value = $this->getObjectValue($parameterValue, $property); |
|
140 | 140 | |
141 | - if(($handler=$this->createTypeHandler($property, $registry))!==null) |
|
141 | + if (($handler = $this->createTypeHandler($property, $registry)) !== null) |
|
142 | 142 | $value = $handler->getParameter($value); |
143 | 143 | |
144 | - $value = $this->nullifyDefaultValue($property,$value); |
|
144 | + $value = $this->nullifyDefaultValue($property, $value); |
|
145 | 145 | |
146 | - if(($type = $property->getType())!==null) |
|
146 | + if (($type = $property->getType()) !== null) |
|
147 | 147 | $value = $registry->convertToType($type, $value); |
148 | 148 | |
149 | 149 | return $value; |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function createTypeHandler($property, $registry) |
160 | 160 | { |
161 | - $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
|
162 | - $handler=$registry->getTypeHandler($type); |
|
163 | - if($handler===null && $property->getTypeHandler()) |
|
161 | + $type = $property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
|
162 | + $handler = $registry->getTypeHandler($type); |
|
163 | + if ($handler === null && $property->getTypeHandler()) |
|
164 | 164 | $handler = Prado::createComponent($type); |
165 | 165 | return $handler; |
166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return mixed property value. |
173 | 173 | * @throws TSqlMapException if property access is invalid. |
174 | 174 | */ |
175 | - protected function getObjectValue($object,$property) |
|
175 | + protected function getObjectValue($object, $property) |
|
176 | 176 | { |
177 | 177 | try |
178 | 178 | { |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | * @param mixed current property value |
197 | 197 | * @return mixed null if NullValue matches currrent value. |
198 | 198 | */ |
199 | - protected function nullifyDefaultValue($property,$value) |
|
199 | + protected function nullifyDefaultValue($property, $value) |
|
200 | 200 | { |
201 | - if(($nullValue = $property->getNullValue())!==null) |
|
201 | + if (($nullValue = $property->getNullValue()) !== null) |
|
202 | 202 | { |
203 | - if($nullValue === $value) |
|
203 | + if ($nullValue === $value) |
|
204 | 204 | $value = null; |
205 | 205 | } |
206 | 206 | return $value; |
@@ -177,8 +177,7 @@ |
||
177 | 177 | try |
178 | 178 | { |
179 | 179 | return TPropertyAccess::get($object, $property->getProperty()); |
180 | - } |
|
181 | - catch (TInvalidPropertyException $e) |
|
180 | + } catch (TInvalidPropertyException $e) |
|
182 | 181 | { |
183 | 182 | throw new TSqlMapException( |
184 | 183 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -103,6 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @param string name of the column in the result set from which the value |
105 | 105 | * will be used to populate the property. |
106 | + * @param string $value |
|
106 | 107 | */ |
107 | 108 | public function setColumn($value) |
108 | 109 | { |
@@ -121,6 +122,7 @@ discard block |
||
121 | 122 | /** |
122 | 123 | * @param int index of the column in the ResultSet from which the value will |
123 | 124 | * be used to populate the object property |
125 | + * @param integer $value |
|
124 | 126 | */ |
125 | 127 | public function setColumnIndex($value) |
126 | 128 | { |
@@ -185,6 +187,7 @@ discard block |
||
185 | 187 | |
186 | 188 | /** |
187 | 189 | * @param string custom type handler class name (may use namespace). |
190 | + * @param string $value |
|
188 | 191 | */ |
189 | 192 | public function setTypeHandler($value) |
190 | 193 | { |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | private $_nullValue; |
37 | 37 | private $_propertyName; |
38 | 38 | private $_columnName; |
39 | - private $_columnIndex=-1; |
|
39 | + private $_columnIndex = -1; |
|
40 | 40 | private $_nestedResultMapName; |
41 | 41 | private $_nestedResultMap; |
42 | 42 | private $_valueType; |
43 | 43 | private $_typeHandler; |
44 | - private $_isLazyLoad=false; |
|
44 | + private $_isLazyLoad = false; |
|
45 | 45 | private $_select; |
46 | 46 | |
47 | - private $_hostResultMapID='inplicit internal mapping'; |
|
47 | + private $_hostResultMapID = 'inplicit internal mapping'; |
|
48 | 48 | |
49 | 49 | const LIST_TYPE = 0; |
50 | 50 | const ARRAY_TYPE = 1; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * Gets the containing result map ID. |
54 | 54 | * @param TResultMap containing result map. |
55 | 55 | */ |
56 | - public function __construct($resultMap=null) |
|
56 | + public function __construct($resultMap = null) |
|
57 | 57 | { |
58 | - if($resultMap instanceof TResultMap) |
|
58 | + if ($resultMap instanceof TResultMap) |
|
59 | 59 | $this->_hostResultMapID = $resultMap->getID(); |
60 | 60 | } |
61 | 61 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function setLazyLoad($value) |
224 | 224 | { |
225 | - $this->_isLazyLoad = TPropertyValue::ensureBoolean($value,false); |
|
225 | + $this->_isLazyLoad = TPropertyValue::ensureBoolean($value, false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | * @param array result row |
232 | 232 | * @return mixed property value. |
233 | 233 | */ |
234 | - public function getPropertyValue($registry,$row) |
|
234 | + public function getPropertyValue($registry, $row) |
|
235 | 235 | { |
236 | 236 | $value = null; |
237 | 237 | $index = $this->getColumnIndex(); |
238 | 238 | $name = $this->getColumn(); |
239 | - if($index > 0 && isset($row[$index])) |
|
240 | - $value = $this->getTypedValue($registry,$row[$index]); |
|
241 | - else if(isset($row[$name])) |
|
242 | - $value = $this->getTypedValue($registry,$row[$name]); |
|
243 | - if(($value===null) && ($this->getNullValue()!==null)) |
|
244 | - $value = $this->getTypedValue($registry,$this->getNullValue()); |
|
239 | + if ($index > 0 && isset($row[$index])) |
|
240 | + $value = $this->getTypedValue($registry, $row[$index]); |
|
241 | + else if (isset($row[$name])) |
|
242 | + $value = $this->getTypedValue($registry, $row[$name]); |
|
243 | + if (($value === null) && ($this->getNullValue() !== null)) |
|
244 | + $value = $this->getTypedValue($registry, $this->getNullValue()); |
|
245 | 245 | return $value; |
246 | 246 | } |
247 | 247 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * @param mixed raw property value |
251 | 251 | * @return mixed property value casted to specific type. |
252 | 252 | */ |
253 | - protected function getTypedValue($registry,$value) |
|
253 | + protected function getTypedValue($registry, $value) |
|
254 | 254 | { |
255 | - if(($handler = $this->createTypeHandler($registry))!==null) |
|
255 | + if (($handler = $this->createTypeHandler($registry)) !== null) |
|
256 | 256 | return $handler->getResult($value); |
257 | 257 | else |
258 | 258 | return $registry->convertToType($this->getType(), $value); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function createTypeHandler($registry) |
267 | 267 | { |
268 | - $type=$this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
|
269 | - $handler=$registry->getTypeHandler($type); |
|
270 | - if($handler===null && $this->getTypeHandler()) |
|
268 | + $type = $this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
|
269 | + $handler = $registry->getTypeHandler($type); |
|
270 | + if ($handler === null && $this->getTypeHandler()) |
|
271 | 271 | $handler = Prado::createComponent($type); |
272 | 272 | return $handler; |
273 | 273 | } |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | */ |
279 | 279 | protected function getPropertyValueType() |
280 | 280 | { |
281 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
281 | + if (class_exists($type = $this->getType(), false)) //NO force autoloading |
|
282 | 282 | { |
283 | - if($type==='TList') |
|
283 | + if ($type === 'TList') |
|
284 | 284 | return self::LIST_TYPE; |
285 | 285 | $class = new ReflectionClass($type); |
286 | - if($class->isSubclassOf('TList')) |
|
286 | + if ($class->isSubclassOf('TList')) |
|
287 | 287 | return self::LIST_TYPE; |
288 | - if($class->implementsInterface('ArrayAccess')) |
|
288 | + if ($class->implementsInterface('ArrayAccess')) |
|
289 | 289 | return self::ARRAY_TYPE; |
290 | 290 | } |
291 | - if(strtolower($type) == 'array') |
|
291 | + if (strtolower($type) == 'array') |
|
292 | 292 | return self::ARRAY_TYPE; |
293 | 293 | } |
294 | 294 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function instanceOfListType($target) |
302 | 302 | { |
303 | - if($this->getType()===null) |
|
304 | - return TPropertyAccess::get($target,$this->getProperty()) instanceof TList; |
|
303 | + if ($this->getType() === null) |
|
304 | + return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
|
305 | 305 | return $this->getPropertyValueType() == self::LIST_TYPE; |
306 | 306 | } |
307 | 307 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function instanceOfArrayType($target) |
315 | 315 | { |
316 | - if($this->getType()===null) |
|
316 | + if ($this->getType() === null) |
|
317 | 317 | { |
318 | - $prop = TPropertyAccess::get($target,$this->getProperty()); |
|
319 | - if(is_object($prop)) |
|
318 | + $prop = TPropertyAccess::get($target, $this->getProperty()); |
|
319 | + if (is_object($prop)) |
|
320 | 320 | return $prop instanceof ArrayAccess; |
321 | 321 | return is_array($prop); |
322 | 322 | } |
@@ -326,17 +326,17 @@ discard block |
||
326 | 326 | public function __sleep() |
327 | 327 | { |
328 | 328 | $exprops = array(); $cn = 'TResultProperty'; |
329 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
330 | - if ($this->_propertyName===null) $exprops[] = "\0$cn\0_propertyNama"; |
|
331 | - if ($this->_columnName===null) $exprops[] = "\0$cn\0_columnName"; |
|
332 | - if ($this->_columnIndex==-1) $exprops[] = "\0$cn\0_columnIndex"; |
|
333 | - if ($this->_nestedResultMapName===null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
334 | - if ($this->_nestedResultMap===null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
335 | - if ($this->_valueType===null) $exprops[] = "\0$cn\0_valueType"; |
|
336 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
337 | - if ($this->_isLazyLoad===false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
338 | - if ($this->_select===null) $exprops[] = "\0$cn\0_select"; |
|
339 | - return array_diff(parent::__sleep(),$exprops); |
|
329 | + if ($this->_nullValue === null) $exprops[] = "\0$cn\0_nullValue"; |
|
330 | + if ($this->_propertyName === null) $exprops[] = "\0$cn\0_propertyNama"; |
|
331 | + if ($this->_columnName === null) $exprops[] = "\0$cn\0_columnName"; |
|
332 | + if ($this->_columnIndex == -1) $exprops[] = "\0$cn\0_columnIndex"; |
|
333 | + if ($this->_nestedResultMapName === null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
334 | + if ($this->_nestedResultMap === null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
335 | + if ($this->_valueType === null) $exprops[] = "\0$cn\0_valueType"; |
|
336 | + if ($this->_typeHandler === null) $exprops[] = "\0$cn\0_typeHandler"; |
|
337 | + if ($this->_isLazyLoad === false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
338 | + if ($this->_select === null) $exprops[] = "\0$cn\0_select"; |
|
339 | + return array_diff(parent::__sleep(), $exprops); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 |
@@ -268,6 +268,7 @@ |
||
268 | 268 | * @param TSqlMapTypeHandlerRegistry type handler registry |
269 | 269 | * @param string result class name. |
270 | 270 | * @param array result data. |
271 | + * @param string $type |
|
271 | 272 | * @return mixed result object. |
272 | 273 | */ |
273 | 274 | protected function createInstanceOf($registry,$type,$row=null) |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function setID($value) |
57 | 57 | { |
58 | - $this->_ID=$value; |
|
58 | + $this->_ID = $value; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function initialize($manager) |
248 | 248 | { |
249 | - if(strlen($this->_resultMapName) > 0) |
|
249 | + if (strlen($this->_resultMapName) > 0) |
|
250 | 250 | $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
251 | - if(strlen($this->_parameterMapName) > 0) |
|
251 | + if (strlen($this->_parameterMapName) > 0) |
|
252 | 252 | $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
253 | 253 | } |
254 | 254 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function createInstanceOfListClass($registry) |
260 | 260 | { |
261 | - if(strlen($type = $this->getListClass()) > 0) |
|
262 | - return $this->createInstanceOf($registry,$type); |
|
261 | + if (strlen($type = $this->getListClass()) > 0) |
|
262 | + return $this->createInstanceOf($registry, $type); |
|
263 | 263 | return array(); |
264 | 264 | } |
265 | 265 | |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | * @param array result data. |
271 | 271 | * @return mixed result object. |
272 | 272 | */ |
273 | - protected function createInstanceOf($registry,$type,$row=null) |
|
273 | + protected function createInstanceOf($registry, $type, $row = null) |
|
274 | 274 | { |
275 | 275 | $handler = $registry->getTypeHandler($type); |
276 | - if($handler!==null) |
|
276 | + if ($handler !== null) |
|
277 | 277 | return $handler->createNewInstance($row); |
278 | 278 | else |
279 | 279 | return $registry->createInstanceOf($type); |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * @param array result data. |
286 | 286 | * @return mixed result object. |
287 | 287 | */ |
288 | - public function createInstanceOfResultClass($registry,$row) |
|
288 | + public function createInstanceOfResultClass($registry, $row) |
|
289 | 289 | { |
290 | - if(strlen($type= $this->getResultClass()) > 0) |
|
291 | - return $this->createInstanceOf($registry,$type,$row); |
|
290 | + if (strlen($type = $this->getResultClass()) > 0) |
|
291 | + return $this->createInstanceOf($registry, $type, $row); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | public function __sleep() |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
309 | 309 | if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
310 | 310 | |
311 | - return array_diff(parent::__sleep(),$exprops); |
|
311 | + return array_diff(parent::__sleep(), $exprops); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | { |
325 | 325 | private $_generate; |
326 | 326 | |
327 | - public function getGenerate(){ return $this->_generate; } |
|
328 | - public function setGenerate($value){ $this->_generate = $value; } |
|
327 | + public function getGenerate() { return $this->_generate; } |
|
328 | + public function setGenerate($value) { $this->_generate = $value; } |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | class TSqlMapInsert extends TSqlMapStatement |
342 | 342 | { |
343 | - private $_selectKey=null; |
|
343 | + private $_selectKey = null; |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * @return TSqlMapSelectKey select key element. |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Create an instance of an object give by the attribute named 'class' in the |
24 | 24 | * node and set the properties on the object given by attribute names and values. |
25 | 25 | * @param SimpleXmlNode property node |
26 | - * @return Object new instance of class with class name given by 'class' attribute value. |
|
26 | + * @return TComponent new instance of class with class name given by 'class' attribute value. |
|
27 | 27 | */ |
28 | 28 | protected function createObjectFromNode($node) |
29 | 29 | { |
@@ -44,6 +44,7 @@ discard block |
||
44 | 44 | * @param Object object instance |
45 | 45 | * @param SimpleXmlNode property node |
46 | 46 | * @param array exception property name |
47 | + * @param TComponent $obj |
|
47 | 48 | */ |
48 | 49 | protected function setObjectPropFromNode($obj,$node,$except=array()) |
49 | 50 | { |
@@ -65,6 +66,8 @@ discard block |
||
65 | 66 | * Gets the filename relative to the basefile. |
66 | 67 | * @param string base filename |
67 | 68 | * @param string relative filename |
69 | + * @param string $basefile |
|
70 | + * @param string $resource |
|
68 | 71 | * @return string absolute filename. |
69 | 72 | */ |
70 | 73 | protected function getAbsoluteFilePath($basefile,$resource) |
@@ -98,9 +101,10 @@ discard block |
||
98 | 101 | |
99 | 102 | /** |
100 | 103 | * Get element node by ID value (try for attribute name ID as case insensitive). |
101 | - * @param SimpleXmlDocument $document |
|
104 | + * @param SimpleXMLElement $document |
|
102 | 105 | * @param string tag name. |
103 | 106 | * @param string id value. |
107 | + * @param string $tag |
|
104 | 108 | * @return SimpleXmlElement node if found, null otherwise. |
105 | 109 | */ |
106 | 110 | protected function getElementByIdValue($document, $tag, $value) |
@@ -146,6 +150,7 @@ discard block |
||
146 | 150 | |
147 | 151 | /** |
148 | 152 | * @param TSqlMapManager manager instance. |
153 | + * @param TSqlMapManager $manager |
|
149 | 154 | */ |
150 | 155 | public function __construct($manager) |
151 | 156 | { |
@@ -524,6 +529,7 @@ discard block |
||
524 | 529 | * in the sql text. Extracts inline parameter maps. |
525 | 530 | * @param TSqlMapStatement mapped statement. |
526 | 531 | * @param SimpleXmlElement statement node. |
532 | + * @param TSqlMapStatement $statement |
|
527 | 533 | */ |
528 | 534 | protected function processSqlStatement($statement, $node) |
529 | 535 | { |
@@ -547,6 +553,7 @@ discard block |
||
547 | 553 | * @param TSqlMapStatement statement object. |
548 | 554 | * @param string sql text |
549 | 555 | * @param SimpleXmlElement statement node. |
556 | + * @param string $sqlStatement |
|
550 | 557 | */ |
551 | 558 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
552 | 559 | { |
@@ -644,6 +651,7 @@ discard block |
||
644 | 651 | /** |
645 | 652 | * Load the selectKey statement from xml mapping. |
646 | 653 | * @param SimpleXmlElement selectkey node |
654 | + * @param TSqlMapInsert $insert |
|
647 | 655 | */ |
648 | 656 | protected function loadSelectKeyTag($insert, $node) |
649 | 657 | { |
@@ -734,6 +742,7 @@ discard block |
||
734 | 742 | * Load the flush interval |
735 | 743 | * @param TSqlMapCacheModel cache model |
736 | 744 | * @param SimpleXmlElement cache node |
745 | + * @param TSqlMapCacheModel $cacheModel |
|
737 | 746 | */ |
738 | 747 | protected function loadFlushInterval($cacheModel, $node) |
739 | 748 | { |
@@ -769,6 +778,7 @@ discard block |
||
769 | 778 | * @param TSqlMapCacheModel cache model |
770 | 779 | * @param SimpleXmlElement parent node. |
771 | 780 | * @param SimpleXmlElement flush node. |
781 | + * @param TSqlMapCacheModel $cacheModel |
|
772 | 782 | */ |
773 | 783 | protected function loadFlushOnCache($cacheModel,$parent,$node) |
774 | 784 | { |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function createObjectFromNode($node) |
29 | 29 | { |
30 | - if(isset($node['class'])) |
|
30 | + if (isset($node['class'])) |
|
31 | 31 | { |
32 | - $obj = Prado::createComponent((string)$node['class']); |
|
33 | - $this->setObjectPropFromNode($obj,$node,array('class')); |
|
32 | + $obj = Prado::createComponent((string) $node['class']); |
|
33 | + $this->setObjectPropFromNode($obj, $node, array('class')); |
|
34 | 34 | return $obj; |
35 | 35 | } |
36 | 36 | throw new TSqlMapConfigurationException( |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @param SimpleXmlNode property node |
46 | 46 | * @param array exception property name |
47 | 47 | */ |
48 | - protected function setObjectPropFromNode($obj,$node,$except=array()) |
|
48 | + protected function setObjectPropFromNode($obj, $node, $except = array()) |
|
49 | 49 | { |
50 | - foreach($node->attributes() as $name=>$value) |
|
50 | + foreach ($node->attributes() as $name=>$value) |
|
51 | 51 | { |
52 | - if(!in_array($name,$except)) |
|
52 | + if (!in_array($name, $except)) |
|
53 | 53 | { |
54 | - if($obj->canSetProperty($name)) |
|
55 | - $obj->{$name} = (string)$value; |
|
54 | + if ($obj->canSetProperty($name)) |
|
55 | + $obj->{$name} = (string) $value; |
|
56 | 56 | else |
57 | 57 | throw new TSqlMapConfigurationException( |
58 | 58 | 'sqlmap_invalid_property', $name, get_class($obj), |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * @param string relative filename |
68 | 68 | * @return string absolute filename. |
69 | 69 | */ |
70 | - protected function getAbsoluteFilePath($basefile,$resource) |
|
70 | + protected function getAbsoluteFilePath($basefile, $resource) |
|
71 | 71 | { |
72 | 72 | $basedir = dirname($basefile); |
73 | - $file = realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
74 | - if(!is_string($file) || !is_file($file)) |
|
73 | + $file = realpath($basedir . DIRECTORY_SEPARATOR . $resource); |
|
74 | + if (!is_string($file) || !is_file($file)) |
|
75 | 75 | $file = realpath($resource); |
76 | - if(is_string($file) && is_file($file)) |
|
76 | + if (is_string($file) && is_file($file)) |
|
77 | 77 | return $file; |
78 | 78 | else |
79 | 79 | throw new TSqlMapConfigurationException( |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @param string filename. |
86 | 86 | * @return SimpleXmlElement xml document. |
87 | 87 | */ |
88 | - protected function loadXmlDocument($filename,TSqlMapXmlConfiguration $config) |
|
88 | + protected function loadXmlDocument($filename, TSqlMapXmlConfiguration $config) |
|
89 | 89 | { |
90 | - if( strpos($filename, '${') !== false) |
|
90 | + if (strpos($filename, '${') !== false) |
|
91 | 91 | $filename = $config->replaceProperties($filename); |
92 | 92 | |
93 | - if(!is_file($filename)) |
|
93 | + if (!is_file($filename)) |
|
94 | 94 | throw new TSqlMapConfigurationException( |
95 | 95 | 'sqlmap_unable_to_find_config', $filename); |
96 | 96 | return simplexml_load_string($config->replaceProperties(file_get_contents($filename))); |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | protected function getElementByIdValue($document, $tag, $value) |
107 | 107 | { |
108 | 108 | //hack to allow upper case and lower case attribute names. |
109 | - foreach(array('id','ID','Id', 'iD') as $id) |
|
109 | + foreach (array('id', 'ID', 'Id', 'iD') as $id) |
|
110 | 110 | { |
111 | 111 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
112 | - foreach($document->xpath($xpath) as $node) |
|
112 | + foreach ($document->xpath($xpath) as $node) |
|
113 | 113 | return $node; |
114 | 114 | } |
115 | 115 | } |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @var array global properties. |
144 | 144 | */ |
145 | - private $_properties=array(); |
|
145 | + private $_properties = array(); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * @param TSqlMapManager manager instance. |
149 | 149 | */ |
150 | 150 | public function __construct($manager) |
151 | 151 | { |
152 | - $this->_manager=$manager; |
|
152 | + $this->_manager = $manager; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function getManager() |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | * Configure the TSqlMapManager using the given xml file. |
167 | 167 | * @param string SqlMap configuration xml file. |
168 | 168 | */ |
169 | - public function configure($filename=null) |
|
169 | + public function configure($filename = null) |
|
170 | 170 | { |
171 | - $this->_configFile=$filename; |
|
172 | - $document = $this->loadXmlDocument($filename,$this); |
|
171 | + $this->_configFile = $filename; |
|
172 | + $document = $this->loadXmlDocument($filename, $this); |
|
173 | 173 | |
174 | - foreach($document->xpath('//property') as $property) |
|
174 | + foreach ($document->xpath('//property') as $property) |
|
175 | 175 | $this->loadGlobalProperty($property); |
176 | 176 | |
177 | - foreach($document->xpath('//typeHandler') as $handler) |
|
177 | + foreach ($document->xpath('//typeHandler') as $handler) |
|
178 | 178 | $this->loadTypeHandler($handler); |
179 | 179 | |
180 | - foreach($document->xpath('//connection[last()]') as $conn) |
|
180 | + foreach ($document->xpath('//connection[last()]') as $conn) |
|
181 | 181 | $this->loadDatabaseConnection($conn); |
182 | 182 | |
183 | 183 | //try to load configuration in the current config file. |
184 | 184 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
185 | 185 | $mapping->configure($filename); |
186 | 186 | |
187 | - foreach($document->xpath('//sqlMap') as $sqlmap) |
|
187 | + foreach ($document->xpath('//sqlMap') as $sqlmap) |
|
188 | 188 | $this->loadSqlMappingFiles($sqlmap); |
189 | 189 | |
190 | 190 | $this->resolveResultMapping(); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function loadGlobalProperty($node) |
199 | 199 | { |
200 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
200 | + $this->_properties[(string) $node['name']] = (string) $node['value']; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function loadSqlMappingFiles($node) |
228 | 228 | { |
229 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
229 | + if (strlen($resource = (string) $node['resource']) > 0) |
|
230 | 230 | { |
231 | - if( strpos($resource, '${') !== false) |
|
231 | + if (strpos($resource, '${') !== false) |
|
232 | 232 | $resource = $this->replaceProperties($resource); |
233 | 233 | |
234 | 234 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | protected function resolveResultMapping() |
244 | 244 | { |
245 | 245 | $maps = $this->_manager->getResultMaps(); |
246 | - foreach($maps as $entry) |
|
246 | + foreach ($maps as $entry) |
|
247 | 247 | { |
248 | - foreach($entry->getColumns() as $item) |
|
248 | + foreach ($entry->getColumns() as $item) |
|
249 | 249 | { |
250 | 250 | $resultMap = $item->getResultMapping(); |
251 | - if(strlen($resultMap) > 0) |
|
251 | + if (strlen($resultMap) > 0) |
|
252 | 252 | { |
253 | - if($maps->contains($resultMap)) |
|
253 | + if ($maps->contains($resultMap)) |
|
254 | 254 | $item->setNestedResultMap($maps[$resultMap]); |
255 | 255 | else |
256 | 256 | throw new TSqlMapConfigurationException( |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $resultMap, $this->_configFile, $entry->getID()); |
259 | 259 | } |
260 | 260 | } |
261 | - if($entry->getDiscriminator()!==null) |
|
261 | + if ($entry->getDiscriminator() !== null) |
|
262 | 262 | $entry->getDiscriminator()->initialize($this->_manager); |
263 | 263 | } |
264 | 264 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function attachCacheModels() |
270 | 270 | { |
271 | - foreach($this->_manager->getMappedStatements() as $mappedStatement) |
|
271 | + foreach ($this->_manager->getMappedStatements() as $mappedStatement) |
|
272 | 272 | { |
273 | - if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
273 | + if (strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
274 | 274 | { |
275 | 275 | $cache = $this->_manager->getCacheModel($model); |
276 | 276 | $mappedStatement->getStatement()->setCache($cache); |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function replaceProperties($string) |
288 | 288 | { |
289 | - foreach($this->_properties as $find => $replace) |
|
290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
289 | + foreach ($this->_properties as $find => $replace) |
|
290 | + $string = str_replace('${' . $find . '}', $replace, $string); |
|
291 | 291 | return $string; |
292 | 292 | } |
293 | 293 | } |
@@ -309,25 +309,25 @@ discard block |
||
309 | 309 | |
310 | 310 | private $_document; |
311 | 311 | |
312 | - private $_FlushOnExecuteStatements=array(); |
|
312 | + private $_FlushOnExecuteStatements = array(); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * Regular expressions for escaping simple/inline parameter symbols |
316 | 316 | */ |
317 | - const SIMPLE_MARK='$'; |
|
318 | - const INLINE_SYMBOL='#'; |
|
319 | - const ESCAPED_SIMPLE_MARK_REGEXP='/\$\$/'; |
|
320 | - const ESCAPED_INLINE_SYMBOL_REGEXP='/\#\#/'; |
|
321 | - const SIMPLE_PLACEHOLDER='`!!`'; |
|
322 | - const INLINE_PLACEHOLDER='`!!!`'; |
|
317 | + const SIMPLE_MARK = '$'; |
|
318 | + const INLINE_SYMBOL = '#'; |
|
319 | + const ESCAPED_SIMPLE_MARK_REGEXP = '/\$\$/'; |
|
320 | + const ESCAPED_INLINE_SYMBOL_REGEXP = '/\#\#/'; |
|
321 | + const SIMPLE_PLACEHOLDER = '`!!`'; |
|
322 | + const INLINE_PLACEHOLDER = '`!!!`'; |
|
323 | 323 | |
324 | 324 | /** |
325 | 325 | * @param TSqlMapXmlConfiguration parent xml configuration. |
326 | 326 | */ |
327 | 327 | public function __construct(TSqlMapXmlConfiguration $xmlConfig) |
328 | 328 | { |
329 | - $this->_xmlConfig=$xmlConfig; |
|
330 | - $this->_manager=$xmlConfig->getManager(); |
|
329 | + $this->_xmlConfig = $xmlConfig; |
|
330 | + $this->_manager = $xmlConfig->getManager(); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | protected function getConfigFile() |
@@ -341,44 +341,44 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function configure($filename) |
343 | 343 | { |
344 | - $this->_configFile=$filename; |
|
345 | - $document = $this->loadXmlDocument($filename,$this->_xmlConfig); |
|
346 | - $this->_document=$document; |
|
344 | + $this->_configFile = $filename; |
|
345 | + $document = $this->loadXmlDocument($filename, $this->_xmlConfig); |
|
346 | + $this->_document = $document; |
|
347 | 347 | |
348 | 348 | static $bCacheDependencies; |
349 | - if($bCacheDependencies === null) |
|
349 | + if ($bCacheDependencies === null) |
|
350 | 350 | $bCacheDependencies = Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
351 | 351 | |
352 | - if($bCacheDependencies) |
|
352 | + if ($bCacheDependencies) |
|
353 | 353 | $this->_manager->getCacheDependencies() |
354 | 354 | ->getDependencies() |
355 | 355 | ->add(new TFileCacheDependency($filename)); |
356 | 356 | |
357 | - foreach($document->xpath('//resultMap') as $node) |
|
357 | + foreach ($document->xpath('//resultMap') as $node) |
|
358 | 358 | $this->loadResultMap($node); |
359 | 359 | |
360 | - foreach($document->xpath('//parameterMap') as $node) |
|
360 | + foreach ($document->xpath('//parameterMap') as $node) |
|
361 | 361 | $this->loadParameterMap($node); |
362 | 362 | |
363 | - foreach($document->xpath('//statement') as $node) |
|
363 | + foreach ($document->xpath('//statement') as $node) |
|
364 | 364 | $this->loadStatementTag($node); |
365 | 365 | |
366 | - foreach($document->xpath('//select') as $node) |
|
366 | + foreach ($document->xpath('//select') as $node) |
|
367 | 367 | $this->loadSelectTag($node); |
368 | 368 | |
369 | - foreach($document->xpath('//insert') as $node) |
|
369 | + foreach ($document->xpath('//insert') as $node) |
|
370 | 370 | $this->loadInsertTag($node); |
371 | 371 | |
372 | - foreach($document->xpath('//update') as $node) |
|
372 | + foreach ($document->xpath('//update') as $node) |
|
373 | 373 | $this->loadUpdateTag($node); |
374 | 374 | |
375 | - foreach($document->xpath('//delete') as $node) |
|
375 | + foreach ($document->xpath('//delete') as $node) |
|
376 | 376 | $this->loadDeleteTag($node); |
377 | 377 | |
378 | - foreach($document->xpath('//procedure') as $node) |
|
378 | + foreach ($document->xpath('//procedure') as $node) |
|
379 | 379 | $this->loadProcedureTag($node); |
380 | 380 | |
381 | - foreach($document->xpath('//cacheModel') as $node) |
|
381 | + foreach ($document->xpath('//cacheModel') as $node) |
|
382 | 382 | $this->loadCacheModel($node); |
383 | 383 | |
384 | 384 | $this->registerCacheTriggers(); |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | $resultMap = $this->createResultMap($node); |
394 | 394 | |
395 | 395 | //find extended result map. |
396 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
396 | + if (strlen($extendMap = $resultMap->getExtends()) > 0) |
|
397 | 397 | { |
398 | - if(!$this->_manager->getResultMaps()->contains($extendMap)) |
|
398 | + if (!$this->_manager->getResultMaps()->contains($extendMap)) |
|
399 | 399 | { |
400 | - $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
|
401 | - if($extendNode!==null) |
|
400 | + $extendNode = $this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
401 | + if ($extendNode !== null) |
|
402 | 402 | $this->loadResultMap($extendNode); |
403 | 403 | } |
404 | 404 | |
405 | - if(!$this->_manager->getResultMaps()->contains($extendMap)) |
|
405 | + if (!$this->_manager->getResultMaps()->contains($extendMap)) |
|
406 | 406 | throw new TSqlMapConfigurationException( |
407 | 407 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | //add the result map |
414 | - if(!$this->_manager->getResultMaps()->contains($resultMap->getID())) |
|
414 | + if (!$this->_manager->getResultMaps()->contains($resultMap->getID())) |
|
415 | 415 | $this->_manager->addResultMap($resultMap); |
416 | 416 | } |
417 | 417 | |
@@ -424,36 +424,36 @@ discard block |
||
424 | 424 | protected function createResultMap($node) |
425 | 425 | { |
426 | 426 | $resultMap = new TResultMap(); |
427 | - $this->setObjectPropFromNode($resultMap,$node); |
|
427 | + $this->setObjectPropFromNode($resultMap, $node); |
|
428 | 428 | |
429 | 429 | //result nodes |
430 | - foreach($node->result as $result) |
|
430 | + foreach ($node->result as $result) |
|
431 | 431 | { |
432 | 432 | $property = new TResultProperty($resultMap); |
433 | - $this->setObjectPropFromNode($property,$result); |
|
433 | + $this->setObjectPropFromNode($property, $result); |
|
434 | 434 | $resultMap->addResultProperty($property); |
435 | 435 | } |
436 | 436 | |
437 | 437 | //create the discriminator |
438 | 438 | $discriminator = null; |
439 | - if(isset($node->discriminator)) |
|
439 | + if (isset($node->discriminator)) |
|
440 | 440 | { |
441 | 441 | $discriminator = new TDiscriminator(); |
442 | 442 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
443 | 443 | $discriminator->initMapping($resultMap); |
444 | 444 | } |
445 | 445 | |
446 | - foreach($node->xpath('subMap') as $subMapNode) |
|
446 | + foreach ($node->xpath('subMap') as $subMapNode) |
|
447 | 447 | { |
448 | - if($discriminator===null) |
|
448 | + if ($discriminator === null) |
|
449 | 449 | throw new TSqlMapConfigurationException( |
450 | - 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
|
450 | + 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
|
451 | 451 | $subMap = new TSubMap; |
452 | - $this->setObjectPropFromNode($subMap,$subMapNode); |
|
452 | + $this->setObjectPropFromNode($subMap, $subMapNode); |
|
453 | 453 | $discriminator->addSubMap($subMap); |
454 | 454 | } |
455 | 455 | |
456 | - if($discriminator!==null) |
|
456 | + if ($discriminator !== null) |
|
457 | 457 | $resultMap->setDiscriminator($discriminator); |
458 | 458 | |
459 | 459 | return $resultMap; |
@@ -468,22 +468,22 @@ discard block |
||
468 | 468 | { |
469 | 469 | $parameterMap = $this->createParameterMap($node); |
470 | 470 | |
471 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
471 | + if (strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
472 | 472 | { |
473 | - if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
473 | + if (!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
474 | 474 | { |
475 | - $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
|
476 | - if($extendNode!==null) |
|
475 | + $extendNode = $this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
476 | + if ($extendNode !== null) |
|
477 | 477 | $this->loadParameterMap($extendNode); |
478 | 478 | } |
479 | 479 | |
480 | - if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
480 | + if (!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
481 | 481 | throw new TSqlMapConfigurationException( |
482 | - 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
|
482 | + 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
|
483 | 483 | $superMap = $this->_manager->getParameterMap($extendMap); |
484 | 484 | $index = 0; |
485 | - foreach($superMap->getPropertyNames() as $propertyName) |
|
486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
485 | + foreach ($superMap->getPropertyNames() as $propertyName) |
|
486 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
487 | 487 | } |
488 | 488 | $this->_manager->addParameterMap($parameterMap); |
489 | 489 | } |
@@ -496,11 +496,11 @@ discard block |
||
496 | 496 | protected function createParameterMap($node) |
497 | 497 | { |
498 | 498 | $parameterMap = new TParameterMap(); |
499 | - $this->setObjectPropFromNode($parameterMap,$node); |
|
500 | - foreach($node->parameter as $parameter) |
|
499 | + $this->setObjectPropFromNode($parameterMap, $node); |
|
500 | + foreach ($node->parameter as $parameter) |
|
501 | 501 | { |
502 | 502 | $property = new TParameterProperty(); |
503 | - $this->setObjectPropFromNode($property,$parameter); |
|
503 | + $this->setObjectPropFromNode($property, $parameter); |
|
504 | 504 | $parameterMap->addProperty($property); |
505 | 505 | } |
506 | 506 | return $parameterMap; |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | protected function loadStatementTag($node) |
514 | 514 | { |
515 | 515 | $statement = new TSqlMapStatement(); |
516 | - $this->setObjectPropFromNode($statement,$node); |
|
516 | + $this->setObjectPropFromNode($statement, $node); |
|
517 | 517 | $this->processSqlStatement($statement, $node); |
518 | 518 | $mappedStatement = new TMappedStatement($this->_manager, $statement); |
519 | 519 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -527,15 +527,15 @@ discard block |
||
527 | 527 | */ |
528 | 528 | protected function processSqlStatement($statement, $node) |
529 | 529 | { |
530 | - $commandText = (string)$node; |
|
531 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
530 | + $commandText = (string) $node; |
|
531 | + if (strlen($extend = $statement->getExtends()) > 0) |
|
532 | 532 | { |
533 | - $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
|
534 | - if($superNode!==null) |
|
535 | - $commandText = (string)$superNode . $commandText; |
|
533 | + $superNode = $this->getElementByIdValue($this->_document, '*', $extend); |
|
534 | + if ($superNode !== null) |
|
535 | + $commandText = (string) $superNode . $commandText; |
|
536 | 536 | else |
537 | 537 | throw new TSqlMapConfigurationException( |
538 | - 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
|
538 | + 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
|
539 | 539 | } |
540 | 540 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
541 | 541 | $statement->initialize($this->_manager); |
@@ -553,24 +553,24 @@ discard block |
||
553 | 553 | $scope['file'] = $this->_configFile; |
554 | 554 | $scope['node'] = $node; |
555 | 555 | |
556 | - $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); |
|
557 | - if($statement->parameterMap() === null) |
|
556 | + $sqlStatement = preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
557 | + if ($statement->parameterMap() === null) |
|
558 | 558 | { |
559 | 559 | // Build a Parametermap with the inline parameters. |
560 | 560 | // if they exist. Then delete inline infos from sqltext. |
561 | 561 | $parameterParser = new TInlineParameterMapParser; |
562 | 562 | $sqlText = $parameterParser->parse($sqlStatement, $scope); |
563 | - if(count($sqlText['parameters']) > 0) |
|
563 | + if (count($sqlText['parameters']) > 0) |
|
564 | 564 | { |
565 | 565 | $map = new TParameterMap(); |
566 | - $map->setID($statement->getID().'-InLineParameterMap'); |
|
566 | + $map->setID($statement->getID() . '-InLineParameterMap'); |
|
567 | 567 | $statement->setInlineParameterMap($map); |
568 | - foreach($sqlText['parameters'] as $property) |
|
568 | + foreach ($sqlText['parameters'] as $property) |
|
569 | 569 | $map->addProperty($property); |
570 | 570 | } |
571 | 571 | $sqlStatement = $sqlText['sql']; |
572 | 572 | } |
573 | - $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); |
|
573 | + $sqlStatement = preg_replace('/' . self::INLINE_PLACEHOLDER . '/', self::INLINE_SYMBOL, $sqlStatement); |
|
574 | 574 | |
575 | 575 | $this->prepareSql($statement, $sqlStatement, $node); |
576 | 576 | } |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | * @param SimpleXmlElement statement node. |
583 | 583 | * @todo Extend to dynamic sql. |
584 | 584 | */ |
585 | - protected function prepareSql($statement,$sqlStatement, $node) |
|
585 | + protected function prepareSql($statement, $sqlStatement, $node) |
|
586 | 586 | { |
587 | 587 | $simpleDynamic = new TSimpleDynamicParser; |
588 | - $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); |
|
588 | + $sqlStatement = preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
589 | 589 | $dynamics = $simpleDynamic->parse($sqlStatement); |
590 | - if(count($dynamics['parameters']) > 0) |
|
590 | + if (count($dynamics['parameters']) > 0) |
|
591 | 591 | { |
592 | 592 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
593 | 593 | $sqlStatement = $dynamics['sql']; |
594 | 594 | } |
595 | 595 | else |
596 | 596 | $sql = new TStaticSql(); |
597 | - $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
|
597 | + $sqlStatement = preg_replace('/' . self::SIMPLE_PLACEHOLDER . '/', self::SIMPLE_MARK, $sqlStatement); |
|
598 | 598 | $sql->buildPreparedStatement($statement, $sqlStatement); |
599 | 599 | $statement->setSqlText($sql); |
600 | 600 | } |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | protected function loadSelectTag($node) |
607 | 607 | { |
608 | 608 | $select = new TSqlMapSelect; |
609 | - $this->setObjectPropFromNode($select,$node); |
|
610 | - $this->processSqlStatement($select,$node); |
|
609 | + $this->setObjectPropFromNode($select, $node); |
|
610 | + $this->processSqlStatement($select, $node); |
|
611 | 611 | $mappedStatement = new TMappedStatement($this->_manager, $select); |
612 | - if(strlen($select->getCacheModel()) > 0) |
|
612 | + if (strlen($select->getCacheModel()) > 0) |
|
613 | 613 | $mappedStatement = new TCachingStatement($mappedStatement); |
614 | 614 | |
615 | 615 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | protected function createInsertStatement($node) |
636 | 636 | { |
637 | 637 | $insert = new TSqlMapInsert; |
638 | - $this->setObjectPropFromNode($insert,$node); |
|
639 | - if(isset($node->selectKey)) |
|
640 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
638 | + $this->setObjectPropFromNode($insert, $node); |
|
639 | + if (isset($node->selectKey)) |
|
640 | + $this->loadSelectKeyTag($insert, $node->selectKey); |
|
641 | 641 | return $insert; |
642 | 642 | } |
643 | 643 | |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | protected function loadSelectKeyTag($insert, $node) |
649 | 649 | { |
650 | 650 | $selectKey = new TSqlMapSelectKey; |
651 | - $this->setObjectPropFromNode($selectKey,$node); |
|
651 | + $this->setObjectPropFromNode($selectKey, $node); |
|
652 | 652 | $selectKey->setID($insert->getID()); |
653 | - $selectKey->setID($insert->getID().'.SelectKey'); |
|
654 | - $this->processSqlStatement($selectKey,$node); |
|
653 | + $selectKey->setID($insert->getID() . '.SelectKey'); |
|
654 | + $this->processSqlStatement($selectKey, $node); |
|
655 | 655 | $insert->setSelectKey($selectKey); |
656 | 656 | $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
657 | 657 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | protected function loadUpdateTag($node) |
665 | 665 | { |
666 | 666 | $update = new TSqlMapUpdate; |
667 | - $this->setObjectPropFromNode($update,$node); |
|
667 | + $this->setObjectPropFromNode($update, $node); |
|
668 | 668 | $this->processSqlStatement($update, $node); |
669 | 669 | $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
670 | 670 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | protected function loadDeleteTag($node) |
678 | 678 | { |
679 | 679 | $delete = new TSqlMapDelete; |
680 | - $this->setObjectPropFromNode($delete,$node); |
|
680 | + $this->setObjectPropFromNode($delete, $node); |
|
681 | 681 | $this->processSqlStatement($delete, $node); |
682 | 682 | $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
683 | 683 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -700,34 +700,34 @@ discard block |
||
700 | 700 | protected function loadCacheModel($node) |
701 | 701 | { |
702 | 702 | $cacheModel = new TSqlMapCacheModel; |
703 | - $properties = array('id','implementation'); |
|
704 | - foreach($node->attributes() as $name=>$value) |
|
703 | + $properties = array('id', 'implementation'); |
|
704 | + foreach ($node->attributes() as $name=>$value) |
|
705 | 705 | { |
706 | - if(in_array(strtolower($name), $properties)) |
|
707 | - $cacheModel->{'set'.$name}((string)$value); |
|
706 | + if (in_array(strtolower($name), $properties)) |
|
707 | + $cacheModel->{'set' . $name}((string) $value); |
|
708 | 708 | } |
709 | 709 | $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
710 | - $this->setObjectPropFromNode($cache,$node,$properties); |
|
710 | + $this->setObjectPropFromNode($cache, $node, $properties); |
|
711 | 711 | |
712 | - foreach($node->xpath('property') as $propertyNode) |
|
712 | + foreach ($node->xpath('property') as $propertyNode) |
|
713 | 713 | { |
714 | 714 | $name = $propertyNode->attributes()->name; |
715 | - if($name===null || $name==='') continue; |
|
715 | + if ($name === null || $name === '') continue; |
|
716 | 716 | |
717 | 717 | $value = $propertyNode->attributes()->value; |
718 | - if($value===null || $value==='') continue; |
|
718 | + if ($value === null || $value === '') continue; |
|
719 | 719 | |
720 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
720 | + if (!TPropertyAccess::has($cache, $name)) continue; |
|
721 | 721 | |
722 | 722 | TPropertyAccess::set($cache, $name, $value); |
723 | 723 | } |
724 | 724 | |
725 | - $this->loadFlushInterval($cacheModel,$node); |
|
725 | + $this->loadFlushInterval($cacheModel, $node); |
|
726 | 726 | |
727 | 727 | $cacheModel->initialize($cache); |
728 | 728 | $this->_manager->addCacheModel($cacheModel); |
729 | - foreach($node->xpath('flushOnExecute') as $flush) |
|
730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
729 | + foreach ($node->xpath('flushOnExecute') as $flush) |
|
730 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -738,26 +738,26 @@ discard block |
||
738 | 738 | protected function loadFlushInterval($cacheModel, $node) |
739 | 739 | { |
740 | 740 | $flushInterval = $node->xpath('flushInterval'); |
741 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
741 | + if ($flushInterval === null || count($flushInterval) === 0) return; |
|
742 | 742 | $duration = 0; |
743 | - foreach($flushInterval[0]->attributes() as $name=>$value) |
|
743 | + foreach ($flushInterval[0]->attributes() as $name=>$value) |
|
744 | 744 | { |
745 | - switch(strToLower($name)) |
|
745 | + switch (strToLower($name)) |
|
746 | 746 | { |
747 | 747 | case 'seconds': |
748 | - $duration += (integer)$value; |
|
748 | + $duration += (integer) $value; |
|
749 | 749 | break; |
750 | 750 | case 'minutes': |
751 | - $duration += 60 * (integer)$value; |
|
751 | + $duration += 60 * (integer) $value; |
|
752 | 752 | break; |
753 | 753 | case 'hours': |
754 | - $duration += 3600 * (integer)$value; |
|
754 | + $duration += 3600 * (integer) $value; |
|
755 | 755 | break; |
756 | 756 | case 'days': |
757 | - $duration += 86400 * (integer)$value; |
|
757 | + $duration += 86400 * (integer) $value; |
|
758 | 758 | break; |
759 | 759 | case 'duration': |
760 | - $duration = (integer)$value; |
|
760 | + $duration = (integer) $value; |
|
761 | 761 | break 2; // switch, foreach |
762 | 762 | } |
763 | 763 | } |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | * @param SimpleXmlElement parent node. |
771 | 771 | * @param SimpleXmlElement flush node. |
772 | 772 | */ |
773 | - protected function loadFlushOnCache($cacheModel,$parent,$node) |
|
773 | + protected function loadFlushOnCache($cacheModel, $parent, $node) |
|
774 | 774 | { |
775 | 775 | $id = $cacheModel->getID(); |
776 | - if(!isset($this->_FlushOnExecuteStatements[$id])) |
|
776 | + if (!isset($this->_FlushOnExecuteStatements[$id])) |
|
777 | 777 | $this->_FlushOnExecuteStatements[$id] = array(); |
778 | - foreach($node->attributes() as $name=>$value) |
|
778 | + foreach ($node->attributes() as $name=>$value) |
|
779 | 779 | { |
780 | - if(strtolower($name)==='statement') |
|
781 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
780 | + if (strtolower($name) === 'statement') |
|
781 | + $this->_FlushOnExecuteStatements[$id][] = (string) $value; |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | */ |
788 | 788 | protected function registerCacheTriggers() |
789 | 789 | { |
790 | - foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
|
790 | + foreach ($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
|
791 | 791 | { |
792 | 792 | $cacheModel = $this->_manager->getCacheModel($cacheID); |
793 | - foreach($statementIDs as $statementID) |
|
793 | + foreach ($statementIDs as $statementID) |
|
794 | 794 | { |
795 | 795 | $statement = $this->_manager->getMappedStatement($statementID); |
796 | 796 | $cacheModel->registerTriggerStatement($statement); |
@@ -109,8 +109,9 @@ discard block |
||
109 | 109 | foreach(array('id','ID','Id', 'iD') as $id) |
110 | 110 | { |
111 | 111 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
112 | - foreach($document->xpath($xpath) as $node) |
|
113 | - return $node; |
|
112 | + foreach($document->xpath($xpath) as $node) { |
|
113 | + return $node; |
|
114 | + } |
|
114 | 115 | } |
115 | 116 | } |
116 | 117 | |
@@ -171,21 +172,25 @@ discard block |
||
171 | 172 | $this->_configFile=$filename; |
172 | 173 | $document = $this->loadXmlDocument($filename,$this); |
173 | 174 | |
174 | - foreach($document->xpath('//property') as $property) |
|
175 | - $this->loadGlobalProperty($property); |
|
175 | + foreach($document->xpath('//property') as $property) { |
|
176 | + $this->loadGlobalProperty($property); |
|
177 | + } |
|
176 | 178 | |
177 | - foreach($document->xpath('//typeHandler') as $handler) |
|
178 | - $this->loadTypeHandler($handler); |
|
179 | + foreach($document->xpath('//typeHandler') as $handler) { |
|
180 | + $this->loadTypeHandler($handler); |
|
181 | + } |
|
179 | 182 | |
180 | - foreach($document->xpath('//connection[last()]') as $conn) |
|
181 | - $this->loadDatabaseConnection($conn); |
|
183 | + foreach($document->xpath('//connection[last()]') as $conn) { |
|
184 | + $this->loadDatabaseConnection($conn); |
|
185 | + } |
|
182 | 186 | |
183 | 187 | //try to load configuration in the current config file. |
184 | 188 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
185 | 189 | $mapping->configure($filename); |
186 | 190 | |
187 | - foreach($document->xpath('//sqlMap') as $sqlmap) |
|
188 | - $this->loadSqlMappingFiles($sqlmap); |
|
191 | + foreach($document->xpath('//sqlMap') as $sqlmap) { |
|
192 | + $this->loadSqlMappingFiles($sqlmap); |
|
193 | + } |
|
189 | 194 | |
190 | 195 | $this->resolveResultMapping(); |
191 | 196 | $this->attachCacheModels(); |
@@ -286,8 +291,9 @@ discard block |
||
286 | 291 | */ |
287 | 292 | public function replaceProperties($string) |
288 | 293 | { |
289 | - foreach($this->_properties as $find => $replace) |
|
290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
294 | + foreach($this->_properties as $find => $replace) { |
|
295 | + $string = str_replace('${'.$find.'}', $replace, $string); |
|
296 | + } |
|
291 | 297 | return $string; |
292 | 298 | } |
293 | 299 | } |
@@ -354,32 +360,41 @@ discard block |
||
354 | 360 | ->getDependencies() |
355 | 361 | ->add(new TFileCacheDependency($filename)); |
356 | 362 | |
357 | - foreach($document->xpath('//resultMap') as $node) |
|
358 | - $this->loadResultMap($node); |
|
363 | + foreach($document->xpath('//resultMap') as $node) { |
|
364 | + $this->loadResultMap($node); |
|
365 | + } |
|
359 | 366 | |
360 | - foreach($document->xpath('//parameterMap') as $node) |
|
361 | - $this->loadParameterMap($node); |
|
367 | + foreach($document->xpath('//parameterMap') as $node) { |
|
368 | + $this->loadParameterMap($node); |
|
369 | + } |
|
362 | 370 | |
363 | - foreach($document->xpath('//statement') as $node) |
|
364 | - $this->loadStatementTag($node); |
|
371 | + foreach($document->xpath('//statement') as $node) { |
|
372 | + $this->loadStatementTag($node); |
|
373 | + } |
|
365 | 374 | |
366 | - foreach($document->xpath('//select') as $node) |
|
367 | - $this->loadSelectTag($node); |
|
375 | + foreach($document->xpath('//select') as $node) { |
|
376 | + $this->loadSelectTag($node); |
|
377 | + } |
|
368 | 378 | |
369 | - foreach($document->xpath('//insert') as $node) |
|
370 | - $this->loadInsertTag($node); |
|
379 | + foreach($document->xpath('//insert') as $node) { |
|
380 | + $this->loadInsertTag($node); |
|
381 | + } |
|
371 | 382 | |
372 | - foreach($document->xpath('//update') as $node) |
|
373 | - $this->loadUpdateTag($node); |
|
383 | + foreach($document->xpath('//update') as $node) { |
|
384 | + $this->loadUpdateTag($node); |
|
385 | + } |
|
374 | 386 | |
375 | - foreach($document->xpath('//delete') as $node) |
|
376 | - $this->loadDeleteTag($node); |
|
387 | + foreach($document->xpath('//delete') as $node) { |
|
388 | + $this->loadDeleteTag($node); |
|
389 | + } |
|
377 | 390 | |
378 | - foreach($document->xpath('//procedure') as $node) |
|
379 | - $this->loadProcedureTag($node); |
|
391 | + foreach($document->xpath('//procedure') as $node) { |
|
392 | + $this->loadProcedureTag($node); |
|
393 | + } |
|
380 | 394 | |
381 | - foreach($document->xpath('//cacheModel') as $node) |
|
382 | - $this->loadCacheModel($node); |
|
395 | + foreach($document->xpath('//cacheModel') as $node) { |
|
396 | + $this->loadCacheModel($node); |
|
397 | + } |
|
383 | 398 | |
384 | 399 | $this->registerCacheTriggers(); |
385 | 400 | } |
@@ -482,8 +497,9 @@ discard block |
||
482 | 497 | 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
483 | 498 | $superMap = $this->_manager->getParameterMap($extendMap); |
484 | 499 | $index = 0; |
485 | - foreach($superMap->getPropertyNames() as $propertyName) |
|
486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
500 | + foreach($superMap->getPropertyNames() as $propertyName) { |
|
501 | + $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
502 | + } |
|
487 | 503 | } |
488 | 504 | $this->_manager->addParameterMap($parameterMap); |
489 | 505 | } |
@@ -565,8 +581,9 @@ discard block |
||
565 | 581 | $map = new TParameterMap(); |
566 | 582 | $map->setID($statement->getID().'-InLineParameterMap'); |
567 | 583 | $statement->setInlineParameterMap($map); |
568 | - foreach($sqlText['parameters'] as $property) |
|
569 | - $map->addProperty($property); |
|
584 | + foreach($sqlText['parameters'] as $property) { |
|
585 | + $map->addProperty($property); |
|
586 | + } |
|
570 | 587 | } |
571 | 588 | $sqlStatement = $sqlText['sql']; |
572 | 589 | } |
@@ -591,8 +608,7 @@ discard block |
||
591 | 608 | { |
592 | 609 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
593 | 610 | $sqlStatement = $dynamics['sql']; |
594 | - } |
|
595 | - else |
|
611 | + } else |
|
596 | 612 | $sql = new TStaticSql(); |
597 | 613 | $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
598 | 614 | $sql->buildPreparedStatement($statement, $sqlStatement); |
@@ -726,8 +742,9 @@ discard block |
||
726 | 742 | |
727 | 743 | $cacheModel->initialize($cache); |
728 | 744 | $this->_manager->addCacheModel($cacheModel); |
729 | - foreach($node->xpath('flushOnExecute') as $flush) |
|
730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
745 | + foreach($node->xpath('flushOnExecute') as $flush) { |
|
746 | + $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
747 | + } |
|
731 | 748 | } |
732 | 749 | |
733 | 750 | /** |