@@ -70,25 +70,25 @@ discard block |
||
70 | 70 | */ |
71 | 71 | class TActiveRecordConfig extends TDataSourceConfig |
72 | 72 | { |
73 | - const DEFAULT_MANAGER_CLASS = 'System.Data.ActiveRecord.TActiveRecordManager'; |
|
74 | - const DEFAULT_GATEWAY_CLASS = 'System.Data.ActiveRecord.TActiveRecordGateway'; |
|
73 | + const DEFAULT_MANAGER_CLASS='System.Data.ActiveRecord.TActiveRecordManager'; |
|
74 | + const DEFAULT_GATEWAY_CLASS='System.Data.ActiveRecord.TActiveRecordGateway'; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Defaults to {@link TActiveRecordConfig::DEFAULT_GATEWAY_CLASS DEFAULT_MANAGER_CLASS} |
78 | 78 | * @var string |
79 | 79 | */ |
80 | - private $_managerClass = self::DEFAULT_MANAGER_CLASS; |
|
80 | + private $_managerClass=self::DEFAULT_MANAGER_CLASS; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Defaults to {@link TActiveRecordConfig::DEFAULT_GATEWAY_CLASS DEFAULT_GATEWAY_CLASS} |
84 | 84 | * @var string |
85 | 85 | */ |
86 | - private $_gatewayClass = self::DEFAULT_GATEWAY_CLASS; |
|
86 | + private $_gatewayClass=self::DEFAULT_GATEWAY_CLASS; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @var TActiveRecordManager |
90 | 90 | */ |
91 | - private $_manager = null; |
|
91 | + private $_manager=null; |
|
92 | 92 | |
93 | 93 | private $_enableCache=false; |
94 | 94 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @var TActiveRecordInvalidFinderResult |
99 | 99 | * @since 3.1.5 |
100 | 100 | */ |
101 | - private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null; |
|
101 | + private $_invalidFinderResult=TActiveRecordInvalidFinderResult::Null; |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Initialize the active record manager. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public function init($xml) |
108 | 108 | { |
109 | 109 | parent::init($xml); |
110 | - $manager = $this -> getManager(); |
|
110 | + $manager=$this -> getManager(); |
|
111 | 111 | if($this->getEnableCache()) |
112 | 112 | $manager->setCache($this->getApplication()->getCache()); |
113 | 113 | $manager->setDbConnection($this->getDbConnection()); |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @return TActiveRecordManager |
120 | 120 | */ |
121 | 121 | public function getManager() { |
122 | - if($this->_manager === null) |
|
123 | - $this->_manager = Prado::createComponent($this -> getManagerClass()); |
|
122 | + if($this->_manager===null) |
|
123 | + $this->_manager=Prado::createComponent($this -> getManagerClass()); |
|
124 | 124 | return TActiveRecordManager::getInstance($this->_manager); |
125 | 125 | } |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setManagerClass($value) |
132 | 132 | { |
133 | - $this->_managerClass = TPropertyValue::ensureString($value); |
|
133 | + $this->_managerClass=TPropertyValue::ensureString($value); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function setGatewayClass($value) |
149 | 149 | { |
150 | - $this->_gatewayClass = TPropertyValue::ensureString($value); |
|
150 | + $this->_gatewayClass=TPropertyValue::ensureString($value); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function setEnableCache($value) |
166 | 166 | { |
167 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
167 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -194,6 +194,6 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function setInvalidFinderResult($value) |
196 | 196 | { |
197 | - $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult'); |
|
197 | + $this->_invalidFinderResult=TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult'); |
|
198 | 198 | } |
199 | 199 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | protected function getErrorMessageFile() |
25 | 25 | { |
26 | 26 | $lang=Prado::getPreferredLanguage(); |
27 | - $path = dirname(__FILE__); |
|
27 | + $path=dirname(__FILE__); |
|
28 | 28 | $msgFile=$path.'/messages-'.$lang.'.txt'; |
29 | 29 | if(!is_file($msgFile)) |
30 | 30 | $msgFile=$path.'/messages.txt'; |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function clearCache() |
46 | 46 | { |
47 | - $cache = $this->getApplication()->getCache(); |
|
48 | - if($cache !== null) { |
|
47 | + $cache=$this->getApplication()->getCache(); |
|
48 | + if($cache!==null) { |
|
49 | 49 | $cache->delete($this->getCacheKey()); |
50 | 50 | } |
51 | 51 | } |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getSqlMapManager() { |
62 | 62 | Prado::using('System.Data.SqlMap.TSqlMapManager'); |
63 | - if(($manager = $this->loadCachedSqlMapManager())===null) |
|
63 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
64 | 64 | { |
65 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
65 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
66 | 66 | if(strlen($file=$this->getConfigFile()) > 0) |
67 | 67 | { |
68 | 68 | $manager->configureXml($file); |
69 | 69 | $this->cacheSqlMapManager($manager); |
70 | 70 | } |
71 | 71 | } |
72 | - elseif($this->getConnectionID() !== '') { |
|
72 | + elseif($this->getConnectionID()!=='') { |
|
73 | 73 | $manager->setDbConnection($this->getDbConnection()); |
74 | 74 | } |
75 | 75 | return $manager; |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | { |
84 | 84 | if($this->getEnableCache()) |
85 | 85 | { |
86 | - $cache = $this->getApplication()->getCache(); |
|
87 | - if($cache !== null) { |
|
88 | - $dependencies = null; |
|
89 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
90 | - $dependencies = $manager->getCacheDependencies(); |
|
86 | + $cache=$this->getApplication()->getCache(); |
|
87 | + if($cache!==null) { |
|
88 | + $dependencies=null; |
|
89 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
90 | + $dependencies=$manager->getCacheDependencies(); |
|
91 | 91 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
92 | 92 | } |
93 | 93 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | { |
103 | 103 | if($this->getEnableCache()) |
104 | 104 | { |
105 | - $cache = $this->getApplication()->getCache(); |
|
106 | - if($cache !== null) |
|
105 | + $cache=$this->getApplication()->getCache(); |
|
106 | + if($cache!==null) |
|
107 | 107 | { |
108 | - $manager = $cache->get($this->getCacheKey()); |
|
108 | + $manager=$cache->get($this->getCacheKey()); |
|
109 | 109 | if($manager instanceof TSqlMapManager) |
110 | 110 | return $manager; |
111 | 111 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | $this->_configFile=$value; |
133 | 133 | else |
134 | 134 | { |
135 | - $file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT); |
|
136 | - if($file === null || !is_file($file)) |
|
137 | - throw new TConfigurationException('sqlmap_configfile_invalid',$value); |
|
135 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
136 | + if($file===null || !is_file($file)) |
|
137 | + throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
138 | 138 | else |
139 | - $this->_configFile = $file; |
|
139 | + $this->_configFile=$file; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function setEnableCache($value) |
148 | 148 | { |
149 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
149 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function getClient() |
173 | 173 | { |
174 | - if($this->_sqlmap===null ) |
|
174 | + if($this->_sqlmap===null) |
|
175 | 175 | $this->_sqlmap=$this->createSqlMapGateway(); |
176 | 176 | return $this->_sqlmap; |
177 | 177 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function getTypeHandlers() |
89 | 89 | { |
90 | 90 | if($this->_typeHandlers===null) |
91 | - $this->_typeHandlers= new TSqlMapTypeHandlerRegistry(); |
|
91 | + $this->_typeHandlers=new TSqlMapTypeHandlerRegistry(); |
|
92 | 92 | return $this->_typeHandlers; |
93 | 93 | } |
94 | 94 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function configureXml($file) |
110 | 110 | { |
111 | - $config = new TSqlMapXmlConfiguration($this); |
|
111 | + $config=new TSqlMapXmlConfiguration($this); |
|
112 | 112 | $config->configure($file); |
113 | 113 | } |
114 | 114 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function getCacheDependencies() |
120 | 120 | { |
121 | - if($this->_cacheDependencies === null) |
|
121 | + if($this->_cacheDependencies===null) |
|
122 | 122 | $this->_cacheDependencies=new TChainedCacheDependency(); |
123 | 123 | |
124 | 124 | return $this->_cacheDependencies; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getMappedStatement($name) |
152 | 152 | { |
153 | - if($this->_mappedStatements->contains($name) == false) |
|
153 | + if($this->_mappedStatements->contains($name)==false) |
|
154 | 154 | throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name); |
155 | 155 | return $this->_mappedStatements[$name]; |
156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function addMappedStatement(IMappedStatement $statement) |
165 | 165 | { |
166 | - $key = $statement->getID(); |
|
167 | - if($this->_mappedStatements->contains($key) == true) |
|
166 | + $key=$statement->getID(); |
|
167 | + if($this->_mappedStatements->contains($key)==true) |
|
168 | 168 | throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key); |
169 | 169 | $this->_mappedStatements->add($key, $statement); |
170 | 170 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getResultMap($name) |
187 | 187 | { |
188 | - if($this->_resultMaps->contains($name) == false) |
|
188 | + if($this->_resultMaps->contains($name)==false) |
|
189 | 189 | throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name); |
190 | 190 | return $this->_resultMaps[$name]; |
191 | 191 | } |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function addResultMap(TResultMap $result) |
198 | 198 | { |
199 | - $key = $result->getID(); |
|
200 | - if($this->_resultMaps->contains($key) == true) |
|
199 | + $key=$result->getID(); |
|
200 | + if($this->_resultMaps->contains($key)==true) |
|
201 | 201 | throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key); |
202 | 202 | $this->_resultMaps->add($key, $result); |
203 | 203 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function getParameterMap($name) |
219 | 219 | { |
220 | - if($this->_parameterMaps->contains($name) == false) |
|
220 | + if($this->_parameterMaps->contains($name)==false) |
|
221 | 221 | throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name); |
222 | 222 | return $this->_parameterMaps[$name]; |
223 | 223 | } |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function addParameterMap(TParameterMap $parameter) |
230 | 230 | { |
231 | - $key = $parameter->getID(); |
|
232 | - if($this->_parameterMaps->contains($key) == true) |
|
231 | + $key=$parameter->getID(); |
|
232 | + if($this->_parameterMaps->contains($key)==true) |
|
233 | 233 | throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key); |
234 | 234 | $this->_parameterMaps->add($key, $parameter); |
235 | 235 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function queryForObject($statementName, $parameter=null, $result=null) |
69 | 69 | { |
70 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
70 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
71 | 71 | return $statement->executeQueryForObject($this->getDbConnection(), $parameter, $result); |
72 | 72 | } |
73 | 73 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function queryForList($statementName, $parameter=null, $result=null, $skip=-1, $max=-1) |
90 | 90 | { |
91 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
92 | - return $statement->executeQueryForList($this->getDbConnection(),$parameter, $result, $skip, $max); |
|
91 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
92 | + return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function queryWithRowDelegate($statementName, $delegate, $parameter=null, $result=null, $skip=-1, $max=-1) |
111 | 111 | { |
112 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
112 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
113 | 113 | return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max, $delegate); |
114 | 114 | } |
115 | 115 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0) |
127 | 127 | { |
128 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
128 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
129 | 129 | return new TSqlMapPagedList($statement, $parameter, $pageSize, null, $page); |
130 | 130 | } |
131 | 131 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @param integer The number of the page to initially load into the list. |
145 | 145 | * @return TPagedList A PaginatedList of beans containing the rows. |
146 | 146 | */ |
147 | - public function queryForPagedListWithRowDelegate($statementName,$delegate, $parameter=null, $pageSize=10, $page=0) |
|
147 | + public function queryForPagedListWithRowDelegate($statementName, $delegate, $parameter=null, $pageSize=10, $page=0) |
|
148 | 148 | { |
149 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
150 | - return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate,$page); |
|
149 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
150 | + return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate, $page); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function queryForMap($statementName, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1) |
167 | 167 | { |
168 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
168 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
169 | 169 | return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max); |
170 | 170 | } |
171 | 171 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function queryForMapWithRowDelegate($statementName, $delegate, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1) |
186 | 186 | { |
187 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
187 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
188 | 188 | return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max, $delegate); |
189 | 189 | } |
190 | 190 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function insert($statementName, $parameter=null) |
208 | 208 | { |
209 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
209 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
210 | 210 | return $statement->executeInsert($this->getDbConnection(), $parameter); |
211 | 211 | } |
212 | 212 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function update($statementName, $parameter=null) |
227 | 227 | { |
228 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
228 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
229 | 229 | return $statement->executeUpdate($this->getDbConnection(), $parameter); |
230 | 230 | } |
231 | 231 |
@@ -75,6 +75,6 @@ |
||
75 | 75 | * @param object The result object. |
76 | 76 | * @return object result. |
77 | 77 | */ |
78 | - public function executeQueryForObject($connection,$parameter, $result=null); |
|
78 | + public function executeQueryForObject($connection, $parameter, $result=null); |
|
79 | 79 | } |
80 | 80 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @var boolean true when data is mapped to a particular row. |
46 | 46 | */ |
47 | - private $_IsRowDataFound = false; |
|
47 | + private $_IsRowDataFound=false; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @var TSQLMapObjectCollectionTree group by object collection tree |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @var Post select is to query for list. |
56 | 56 | */ |
57 | - const QUERY_FOR_LIST = 0; |
|
57 | + const QUERY_FOR_LIST=0; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @var Post select is to query for list. |
61 | 61 | */ |
62 | - const QUERY_FOR_ARRAY = 1; |
|
62 | + const QUERY_FOR_ARRAY=1; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var Post select is to query for object. |
66 | 66 | */ |
67 | - const QUERY_FOR_OBJECT = 2; |
|
67 | + const QUERY_FOR_OBJECT=2; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @return string Name used to identify the TMappedStatement amongst the others. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function initialGroupByResults() |
106 | 106 | { |
107 | - $this->_groupBy = new TSqlMapObjectCollectionTree(); |
|
107 | + $this->_groupBy=new TSqlMapObjectCollectionTree(); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function __construct(TSqlMapManager $sqlMap, TSqlMapStatement $statement) |
116 | 116 | { |
117 | - $this->_manager = $sqlMap; |
|
118 | - $this->_statement = $statement; |
|
119 | - $this->_command = new TPreparedCommand(); |
|
117 | + $this->_manager=$sqlMap; |
|
118 | + $this->_statement=$statement; |
|
119 | + $this->_command=new TPreparedCommand(); |
|
120 | 120 | $this->initialGroupByResults(); |
121 | 121 | } |
122 | 122 | |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function executeSQLQueryLimit($connection, $command, $max, $skip) |
163 | 163 | { |
164 | - if($max>-1 || $skip > -1) |
|
164 | + if($max > -1 || $skip > -1) |
|
165 | 165 | { |
166 | - $maxStr=$max>0?' LIMIT '.$max:''; |
|
167 | - $skipStr=$skip>0?' OFFSET '.$skip:''; |
|
166 | + $maxStr=$max > 0 ? ' LIMIT '.$max : ''; |
|
167 | + $skipStr=$skip > 0 ? ' OFFSET '.$skip : ''; |
|
168 | 168 | $command->setText($command->getText().$maxStr.$skipStr); |
169 | 169 | } |
170 | 170 | $connection->setActive(true); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
203 | 203 | { |
204 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); |
|
204 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
205 | 205 | return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate); |
206 | 206 | } |
207 | 207 | |
@@ -224,17 +224,16 @@ discard block |
||
224 | 224 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null) |
225 | 225 | { |
226 | 226 | $registry=$this->getManager()->getTypeHandlers(); |
227 | - $list = $result instanceof ArrayAccess ? $result : |
|
228 | - $this->_statement->createInstanceOfListClass($registry); |
|
227 | + $list=$result instanceof ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
229 | 228 | $connection->setActive(true); |
230 | - $reader = $sql->query(); |
|
229 | + $reader=$sql->query(); |
|
231 | 230 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
232 | 231 | if($delegate!==null) |
233 | 232 | { |
234 | 233 | foreach($reader as $row) |
235 | 234 | { |
236 | - $obj = $this->applyResultMap($row); |
|
237 | - $param = new TResultSetListItemParameter($obj, $parameter, $list); |
|
235 | + $obj=$this->applyResultMap($row); |
|
236 | + $param=new TResultSetListItemParameter($obj, $parameter, $list); |
|
238 | 237 | $this->raiseRowDelegate($delegate, $param); |
239 | 238 | } |
240 | 239 | } |
@@ -244,13 +243,13 @@ discard block |
||
244 | 243 | foreach($reader as $row) |
245 | 244 | { |
246 | 245 | // var_dump($row); |
247 | - $list[] = $this->applyResultMap($row); |
|
246 | + $list[]=$this->applyResultMap($row); |
|
248 | 247 | } |
249 | 248 | } |
250 | 249 | |
251 | 250 | if(!$this->_groupBy->isEmpty()) |
252 | 251 | { |
253 | - $list = $this->_groupBy->collect(); |
|
252 | + $list=$this->_groupBy->collect(); |
|
254 | 253 | $this->initialGroupByResults(); |
255 | 254 | } |
256 | 255 | |
@@ -272,9 +271,9 @@ discard block |
||
272 | 271 | * @param callback row delegate handler |
273 | 272 | * @return array An array of object containing the rows keyed by keyProperty. |
274 | 273 | */ |
275 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
274 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
276 | 275 | { |
277 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
276 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
278 | 277 | return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
279 | 278 | } |
280 | 279 | |
@@ -298,20 +297,19 @@ discard block |
||
298 | 297 | */ |
299 | 298 | public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null) |
300 | 299 | { |
301 | - $map = array(); |
|
300 | + $map=array(); |
|
302 | 301 | //$recordSet = $this->executeSQLQuery($connection, $sql); |
303 | 302 | $connection->setActive(true); |
304 | - $reader = $command->query(); |
|
303 | + $reader=$command->query(); |
|
305 | 304 | if($delegate!==null) |
306 | 305 | { |
307 | 306 | //while($row = $recordSet->fetchRow()) |
308 | 307 | foreach($reader as $row) |
309 | 308 | { |
310 | - $obj = $this->applyResultMap($row); |
|
311 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
312 | - $value = ($valueProperty===null) ? $obj : |
|
313 | - TPropertyAccess::get($obj, $valueProperty); |
|
314 | - $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
309 | + $obj=$this->applyResultMap($row); |
|
310 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
311 | + $value=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
312 | + $param=new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
315 | 313 | $this->raiseRowDelegate($delegate, $param); |
316 | 314 | } |
317 | 315 | } |
@@ -320,10 +318,9 @@ discard block |
||
320 | 318 | //while($row = $recordSet->fetchRow()) |
321 | 319 | foreach($reader as $row) |
322 | 320 | { |
323 | - $obj = $this->applyResultMap($row); |
|
324 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
325 | - $map[$key] = ($valueProperty===null) ? $obj : |
|
326 | - TPropertyAccess::get($obj, $valueProperty); |
|
321 | + $obj=$this->applyResultMap($row); |
|
322 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
323 | + $map[$key]=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
327 | 324 | } |
328 | 325 | } |
329 | 326 | $this->onExecuteQuery($command); |
@@ -340,22 +337,22 @@ discard block |
||
340 | 337 | { |
341 | 338 | if(is_string($handler)) |
342 | 339 | { |
343 | - call_user_func($handler,$this,$param); |
|
340 | + call_user_func($handler, $this, $param); |
|
344 | 341 | } |
345 | - else if(is_callable($handler,true)) |
|
342 | + else if(is_callable($handler, true)) |
|
346 | 343 | { |
347 | 344 | // an array: 0 - object, 1 - method name/path |
348 | - list($object,$method)=$handler; |
|
345 | + list($object, $method)=$handler; |
|
349 | 346 | if(is_string($object)) // static method call |
350 | - call_user_func($handler,$this,$param); |
|
347 | + call_user_func($handler, $this, $param); |
|
351 | 348 | else |
352 | 349 | { |
353 | - if(($pos=strrpos($method,'.'))!==false) |
|
350 | + if(($pos=strrpos($method, '.'))!==false) |
|
354 | 351 | { |
355 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
356 | - $method=substr($method,$pos+1); |
|
352 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
353 | + $method=substr($method, $pos + 1); |
|
357 | 354 | } |
358 | - $object->$method($this,$param); |
|
355 | + $object->$method($this, $param); |
|
359 | 356 | } |
360 | 357 | } |
361 | 358 | else |
@@ -372,7 +369,7 @@ discard block |
||
372 | 369 | */ |
373 | 370 | public function executeQueryForObject($connection, $parameter, $result=null) |
374 | 371 | { |
375 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
372 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
376 | 373 | return $this->runQueryForObject($connection, $sql, $result); |
377 | 374 | } |
378 | 375 | |
@@ -391,16 +388,16 @@ discard block |
||
391 | 388 | */ |
392 | 389 | public function runQueryForObject($connection, $command, &$result) |
393 | 390 | { |
394 | - $object = null; |
|
391 | + $object=null; |
|
395 | 392 | $connection->setActive(true); |
396 | 393 | foreach($command->query() as $row) |
397 | - $object = $this->applyResultMap($row, $result); |
|
394 | + $object=$this->applyResultMap($row, $result); |
|
398 | 395 | |
399 | 396 | if(!$this->_groupBy->isEmpty()) |
400 | 397 | { |
401 | - $list = $this->_groupBy->collect(); |
|
398 | + $list=$this->_groupBy->collect(); |
|
402 | 399 | $this->initialGroupByResults(); |
403 | - $object = $list[0]; |
|
400 | + $object=$list[0]; |
|
404 | 401 | } |
405 | 402 | |
406 | 403 | $this->executePostSelect($connection); |
@@ -418,14 +415,14 @@ discard block |
||
418 | 415 | */ |
419 | 416 | public function executeInsert($connection, $parameter) |
420 | 417 | { |
421 | - $generatedKey = $this->getPreGeneratedSelectKey($connection, $parameter); |
|
418 | + $generatedKey=$this->getPreGeneratedSelectKey($connection, $parameter); |
|
422 | 419 | |
423 | - $command = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
420 | + $command=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
424 | 421 | // var_dump($command,$parameter); |
425 | - $result = $command->execute(); |
|
422 | + $result=$command->execute(); |
|
426 | 423 | |
427 | 424 | if($generatedKey===null) |
428 | - $generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter); |
|
425 | + $generatedKey=$this->getPostGeneratedSelectKey($connection, $parameter); |
|
429 | 426 | |
430 | 427 | $this->executePostSelect($connection); |
431 | 428 | $this->onExecuteQuery($command); |
@@ -442,7 +439,7 @@ discard block |
||
442 | 439 | { |
443 | 440 | if($this->_statement instanceof TSqlMapInsert) |
444 | 441 | { |
445 | - $selectKey = $this->_statement->getSelectKey(); |
|
442 | + $selectKey=$this->_statement->getSelectKey(); |
|
446 | 443 | if(($selectKey!==null) && !$selectKey->getIsAfter()) |
447 | 444 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
448 | 445 | } |
@@ -458,7 +455,7 @@ discard block |
||
458 | 455 | { |
459 | 456 | if($this->_statement instanceof TSqlMapInsert) |
460 | 457 | { |
461 | - $selectKey = $this->_statement->getSelectKey(); |
|
458 | + $selectKey=$this->_statement->getSelectKey(); |
|
462 | 459 | if(($selectKey!==null) && $selectKey->getIsAfter()) |
463 | 460 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
464 | 461 | } |
@@ -473,10 +470,10 @@ discard block |
||
473 | 470 | */ |
474 | 471 | protected function executeSelectKey($connection, $parameter, $selectKey) |
475 | 472 | { |
476 | - $mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID()); |
|
477 | - $generatedKey = $mappedStatement->executeQueryForObject( |
|
473 | + $mappedStatement=$this->getManager()->getMappedStatement($selectKey->getID()); |
|
474 | + $generatedKey=$mappedStatement->executeQueryForObject( |
|
478 | 475 | $connection, $parameter, null); |
479 | - if(strlen($prop = $selectKey->getProperty()) > 0) |
|
476 | + if(strlen($prop=$selectKey->getProperty()) > 0) |
|
480 | 477 | TPropertyAccess::set($parameter, $prop, $generatedKey); |
481 | 478 | return $generatedKey; |
482 | 479 | } |
@@ -490,8 +487,8 @@ discard block |
||
490 | 487 | */ |
491 | 488 | public function executeUpdate($connection, $parameter) |
492 | 489 | { |
493 | - $sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter); |
|
494 | - $affectedRows = $sql->execute(); |
|
490 | + $sql=$this->_command->create($this->getManager(), $connection, $this->_statement, $parameter); |
|
491 | + $affectedRows=$sql->execute(); |
|
495 | 492 | //$this->executeSQLQuery($connection, $sql); |
496 | 493 | $this->executePostSelect($connection); |
497 | 494 | $this->onExecuteQuery($sql); |
@@ -506,24 +503,24 @@ discard block |
||
506 | 503 | { |
507 | 504 | while(count($this->_selectQueue)) |
508 | 505 | { |
509 | - $postSelect = array_shift($this->_selectQueue); |
|
510 | - $method = $postSelect->getMethod(); |
|
511 | - $statement = $postSelect->getStatement(); |
|
512 | - $property = $postSelect->getResultProperty()->getProperty(); |
|
513 | - $keys = $postSelect->getKeys(); |
|
514 | - $resultObject = $postSelect->getResultObject(); |
|
515 | - |
|
516 | - if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY) |
|
506 | + $postSelect=array_shift($this->_selectQueue); |
|
507 | + $method=$postSelect->getMethod(); |
|
508 | + $statement=$postSelect->getStatement(); |
|
509 | + $property=$postSelect->getResultProperty()->getProperty(); |
|
510 | + $keys=$postSelect->getKeys(); |
|
511 | + $resultObject=$postSelect->getResultObject(); |
|
512 | + |
|
513 | + if($method==self::QUERY_FOR_LIST || $method==self::QUERY_FOR_ARRAY) |
|
517 | 514 | { |
518 | - $values = $statement->executeQueryForList($connection, $keys, null); |
|
515 | + $values=$statement->executeQueryForList($connection, $keys, null); |
|
519 | 516 | |
520 | - if($method == self::QUERY_FOR_ARRAY) |
|
521 | - $values = $values->toArray(); |
|
517 | + if($method==self::QUERY_FOR_ARRAY) |
|
518 | + $values=$values->toArray(); |
|
522 | 519 | TPropertyAccess::set($resultObject, $property, $values); |
523 | 520 | } |
524 | - else if($method == self::QUERY_FOR_OBJECT) |
|
521 | + else if($method==self::QUERY_FOR_OBJECT) |
|
525 | 522 | { |
526 | - $value = $statement->executeQueryForObject($connection, $keys, null); |
|
523 | + $value=$statement->executeQueryForObject($connection, $keys, null); |
|
527 | 524 | TPropertyAccess::set($resultObject, $property, $value); |
528 | 525 | } |
529 | 526 | } |
@@ -546,21 +543,21 @@ discard block |
||
546 | 543 | */ |
547 | 544 | protected function applyResultMap($row, &$resultObject=null) |
548 | 545 | { |
549 | - if($row === false) return null; |
|
546 | + if($row===false) return null; |
|
550 | 547 | |
551 | - $resultMapName = $this->_statement->getResultMap(); |
|
552 | - $resultClass = $this->_statement->getResultClass(); |
|
548 | + $resultMapName=$this->_statement->getResultMap(); |
|
549 | + $resultClass=$this->_statement->getResultClass(); |
|
553 | 550 | |
554 | 551 | $obj=null; |
555 | 552 | if($this->getManager()->getResultMaps()->contains($resultMapName)) |
556 | - $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
553 | + $obj=$this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
557 | 554 | else if(strlen($resultClass) > 0) |
558 | - $obj = $this->fillResultClass($resultClass, $row, $resultObject); |
|
555 | + $obj=$this->fillResultClass($resultClass, $row, $resultObject); |
|
559 | 556 | else |
560 | - $obj = $this->fillDefaultResultMap(null, $row, $resultObject); |
|
561 | - if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) |
|
557 | + $obj=$this->fillDefaultResultMap(null, $row, $resultObject); |
|
558 | + if(class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) |
|
562 | 559 | //Create a new clean active record. |
563 | - $obj=TActiveRecord::createRecord(get_class($obj),$obj); |
|
560 | + $obj=TActiveRecord::createRecord(get_class($obj), $obj); |
|
564 | 561 | return $obj; |
565 | 562 | } |
566 | 563 | |
@@ -575,8 +572,8 @@ discard block |
||
575 | 572 | { |
576 | 573 | if($resultObject===null) |
577 | 574 | { |
578 | - $registry = $this->getManager()->getTypeHandlers(); |
|
579 | - $resultObject = $this->_statement->createInstanceOfResultClass($registry,$row); |
|
575 | + $registry=$this->getManager()->getTypeHandlers(); |
|
576 | + $resultObject=$this->_statement->createInstanceOfResultClass($registry, $row); |
|
580 | 577 | } |
581 | 578 | |
582 | 579 | if($resultObject instanceOf ArrayAccess) |
@@ -597,10 +594,10 @@ discard block |
||
597 | 594 | { |
598 | 595 | if($resultObject instanceof TList) |
599 | 596 | foreach($row as $v) |
600 | - $resultObject[] = $v; |
|
597 | + $resultObject[]=$v; |
|
601 | 598 | else |
602 | 599 | foreach($row as $k => $v) |
603 | - $resultObject[$k] = $v; |
|
600 | + $resultObject[$k]=$v; |
|
604 | 601 | return $resultObject; |
605 | 602 | } |
606 | 603 | |
@@ -612,18 +609,18 @@ discard block |
||
612 | 609 | */ |
613 | 610 | protected function fillResultObjectProperty($row, $resultObject) |
614 | 611 | { |
615 | - $index = 0; |
|
612 | + $index=0; |
|
616 | 613 | $registry=$this->getManager()->getTypeHandlers(); |
617 | 614 | foreach($row as $k=>$v) |
618 | 615 | { |
619 | - $property = new TResultProperty; |
|
616 | + $property=new TResultProperty; |
|
620 | 617 | if(is_string($k) && strlen($k) > 0) |
621 | 618 | $property->setColumn($k); |
622 | 619 | $property->setColumnIndex(++$index); |
623 | - $type = gettype(TPropertyAccess::get($resultObject,$k)); |
|
620 | + $type=gettype(TPropertyAccess::get($resultObject, $k)); |
|
624 | 621 | $property->setType($type); |
625 | - $value = $property->getPropertyValue($registry,$row); |
|
626 | - TPropertyAccess::set($resultObject, $k,$value); |
|
622 | + $value=$property->getPropertyValue($registry, $row); |
|
623 | + TPropertyAccess::set($resultObject, $k, $value); |
|
627 | 624 | } |
628 | 625 | return $resultObject; |
629 | 626 | } |
@@ -637,12 +634,12 @@ discard block |
||
637 | 634 | */ |
638 | 635 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
639 | 636 | { |
640 | - $resultMap = $this->getManager()->getResultMap($resultMapName); |
|
641 | - $registry = $this->getManager()->getTypeHandlers(); |
|
642 | - $resultMap = $resultMap->resolveSubMap($registry,$row); |
|
637 | + $resultMap=$this->getManager()->getResultMap($resultMapName); |
|
638 | + $registry=$this->getManager()->getTypeHandlers(); |
|
639 | + $resultMap=$resultMap->resolveSubMap($registry, $row); |
|
643 | 640 | |
644 | 641 | if($resultObject===null) |
645 | - $resultObject = $resultMap->createInstanceOfResult($registry); |
|
642 | + $resultObject=$resultMap->createInstanceOfResult($registry); |
|
646 | 643 | |
647 | 644 | if(is_object($resultObject)) |
648 | 645 | { |
@@ -654,7 +651,7 @@ discard block |
||
654 | 651 | } |
655 | 652 | else |
656 | 653 | { |
657 | - $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
654 | + $resultObject=$this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
658 | 655 | } |
659 | 656 | return $resultObject; |
660 | 657 | } |
@@ -669,11 +666,11 @@ discard block |
||
669 | 666 | */ |
670 | 667 | protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject) |
671 | 668 | { |
672 | - $group = $this->getResultMapGroupKey($resultMap, $row); |
|
669 | + $group=$this->getResultMapGroupKey($resultMap, $row); |
|
673 | 670 | |
674 | 671 | if(empty($parent)) |
675 | 672 | { |
676 | - $rootObject = array('object'=>$resultObject, 'property' => null); |
|
673 | + $rootObject=array('object'=>$resultObject, 'property' => null); |
|
677 | 674 | $this->_groupBy->add(null, $group, $rootObject); |
678 | 675 | } |
679 | 676 | |
@@ -681,23 +678,23 @@ discard block |
||
681 | 678 | { |
682 | 679 | //set properties. |
683 | 680 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
684 | - $nested = $property->getResultMapping(); |
|
681 | + $nested=$property->getResultMapping(); |
|
685 | 682 | |
686 | 683 | //nested property |
687 | 684 | if($this->getManager()->getResultMaps()->contains($nested)) |
688 | 685 | { |
689 | - $nestedMap = $this->getManager()->getResultMap($nested); |
|
690 | - $groupKey = $this->getResultMapGroupKey($nestedMap, $row); |
|
686 | + $nestedMap=$this->getManager()->getResultMap($nested); |
|
687 | + $groupKey=$this->getResultMapGroupKey($nestedMap, $row); |
|
691 | 688 | |
692 | 689 | //add the node reference first |
693 | 690 | if(empty($parent)) |
694 | 691 | $this->_groupBy->add($group, $groupKey, ''); |
695 | 692 | |
696 | 693 | //get the nested result mapping value |
697 | - $value = $this->fillResultMap($nested, $row, $groupKey); |
|
694 | + $value=$this->fillResultMap($nested, $row, $groupKey); |
|
698 | 695 | |
699 | 696 | //add it to the object tree graph |
700 | - $groupObject = array('object'=>$value, 'property' => $property->getProperty()); |
|
697 | + $groupObject=array('object'=>$value, 'property' => $property->getProperty()); |
|
701 | 698 | if(empty($parent)) |
702 | 699 | $this->_groupBy->add($group, $groupKey, $groupObject); |
703 | 700 | else |
@@ -715,7 +712,7 @@ discard block |
||
715 | 712 | */ |
716 | 713 | protected function getResultMapGroupKey($resultMap, $row) |
717 | 714 | { |
718 | - $groupBy = $resultMap->getGroupBy(); |
|
715 | + $groupBy=$resultMap->getGroupBy(); |
|
719 | 716 | if(isset($row[$groupBy])) |
720 | 717 | return $resultMap->getID().$row[$groupBy]; |
721 | 718 | else |
@@ -736,12 +733,12 @@ discard block |
||
736 | 733 | $resultObject=''; |
737 | 734 | |
738 | 735 | if($resultMap!==null) |
739 | - $result = $this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
736 | + $result=$this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
740 | 737 | else |
741 | - $result = $row; |
|
738 | + $result=$row; |
|
742 | 739 | |
743 | 740 | //if scalar result types |
744 | - if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') |
|
741 | + if(count($result)==1 && ($type=gettype($resultObject))!='array') |
|
745 | 742 | return $this->getScalarResult($result, $type); |
746 | 743 | else |
747 | 744 | return $result; |
@@ -756,14 +753,14 @@ discard block |
||
756 | 753 | */ |
757 | 754 | protected function fillArrayResultMap($resultMap, $row, $resultObject) |
758 | 755 | { |
759 | - $result = array(); |
|
756 | + $result=array(); |
|
760 | 757 | $registry=$this->getManager()->getTypeHandlers(); |
761 | 758 | foreach($resultMap->getColumns() as $column) |
762 | 759 | { |
763 | 760 | if(($column->getType()===null) |
764 | 761 | && ($resultObject!==null) && !is_object($resultObject)) |
765 | 762 | $column->setType(gettype($resultObject)); |
766 | - $result[$column->getProperty()] = $column->getPropertyValue($registry,$row); |
|
763 | + $result[$column->getProperty()]=$column->getPropertyValue($registry, $row); |
|
767 | 764 | } |
768 | 765 | return $result; |
769 | 766 | } |
@@ -776,7 +773,7 @@ discard block |
||
776 | 773 | */ |
777 | 774 | protected function getScalarResult($result, $type) |
778 | 775 | { |
779 | - $scalar = array_shift($result); |
|
776 | + $scalar=array_shift($result); |
|
780 | 777 | settype($scalar, $type); |
781 | 778 | return $scalar; |
782 | 779 | } |
@@ -790,23 +787,23 @@ discard block |
||
790 | 787 | */ |
791 | 788 | protected function setObjectProperty($resultMap, $property, $row, &$resultObject) |
792 | 789 | { |
793 | - $select = $property->getSelect(); |
|
794 | - $key = $property->getProperty(); |
|
795 | - $nested = $property->getNestedResultMap(); |
|
790 | + $select=$property->getSelect(); |
|
791 | + $key=$property->getProperty(); |
|
792 | + $nested=$property->getNestedResultMap(); |
|
796 | 793 | $registry=$this->getManager()->getTypeHandlers(); |
797 | - if($key === '') |
|
794 | + if($key==='') |
|
798 | 795 | { |
799 | - $resultObject = $property->getPropertyValue($registry,$row); |
|
796 | + $resultObject=$property->getPropertyValue($registry, $row); |
|
800 | 797 | } |
801 | - else if(strlen($select) == 0 && ($nested===null)) |
|
798 | + else if(strlen($select)==0 && ($nested===null)) |
|
802 | 799 | { |
803 | - $value = $property->getPropertyValue($registry,$row); |
|
800 | + $value=$property->getPropertyValue($registry, $row); |
|
804 | 801 | |
805 | - $this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null); |
|
802 | + $this->_IsRowDataFound=$this->_IsRowDataFound || ($value!=null); |
|
806 | 803 | if(is_array($resultObject) || is_object($resultObject)) |
807 | 804 | TPropertyAccess::set($resultObject, $key, $value); |
808 | 805 | else |
809 | - $resultObject = $value; |
|
806 | + $resultObject=$value; |
|
810 | 807 | } |
811 | 808 | else if($nested!==null) |
812 | 809 | { |
@@ -819,9 +816,9 @@ discard block |
||
819 | 816 | } |
820 | 817 | else |
821 | 818 | { |
822 | - $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
823 | - if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
|
824 | - $obj = null; |
|
819 | + $obj=$nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
820 | + if($this->fillPropertyWithResultMap($nested, $row, $obj)==false) |
|
821 | + $obj=null; |
|
825 | 822 | TPropertyAccess::set($resultObject, $key, $obj); |
826 | 823 | } |
827 | 824 | } |
@@ -841,9 +838,9 @@ discard block |
||
841 | 838 | */ |
842 | 839 | protected function enquequePostSelect($select, $resultMap, $property, $row, $resultObject) |
843 | 840 | { |
844 | - $statement = $this->getManager()->getMappedStatement($select); |
|
845 | - $key = $this->getPostSelectKeys($resultMap, $property, $row); |
|
846 | - $postSelect = new TPostSelectBinding; |
|
841 | + $statement=$this->getManager()->getMappedStatement($select); |
|
842 | + $key=$this->getPostSelectKeys($resultMap, $property, $row); |
|
843 | + $postSelect=new TPostSelectBinding; |
|
847 | 844 | $postSelect->setStatement($statement); |
848 | 845 | $postSelect->setResultObject($resultObject); |
849 | 846 | $postSelect->setResultProperty($property); |
@@ -851,10 +848,10 @@ discard block |
||
851 | 848 | |
852 | 849 | if($property->instanceOfListType($resultObject)) |
853 | 850 | { |
854 | - $values = null; |
|
851 | + $values=null; |
|
855 | 852 | if($property->getLazyLoad()) |
856 | 853 | { |
857 | - $values = TLazyLoadList::newInstance($statement, $key, |
|
854 | + $values=TLazyLoadList::newInstance($statement, $key, |
|
858 | 855 | $resultObject, $property->getProperty()); |
859 | 856 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
860 | 857 | } |
@@ -867,7 +864,7 @@ discard block |
||
867 | 864 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
868 | 865 | |
869 | 866 | if(!$property->getLazyLoad()) |
870 | - $this->_selectQueue[] = $postSelect; |
|
867 | + $this->_selectQueue[]=$postSelect; |
|
871 | 868 | } |
872 | 869 | |
873 | 870 | /** |
@@ -877,23 +874,23 @@ discard block |
||
877 | 874 | * @param array current row data. |
878 | 875 | * @return array list of primary key values. |
879 | 876 | */ |
880 | - protected function getPostSelectKeys($resultMap, $property,$row) |
|
877 | + protected function getPostSelectKeys($resultMap, $property, $row) |
|
881 | 878 | { |
882 | - $value = $property->getColumn(); |
|
883 | - if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0))) |
|
879 | + $value=$property->getColumn(); |
|
880 | + if(is_int(strpos($value.',', 0)) || is_int(strpos($value, '=', 0))) |
|
884 | 881 | { |
885 | - $keys = array(); |
|
882 | + $keys=array(); |
|
886 | 883 | foreach(explode(',', $value) as $entry) |
887 | 884 | { |
888 | - $pair =explode('=',$entry); |
|
889 | - $keys[trim($pair[0])] = $row[trim($pair[1])]; |
|
885 | + $pair=explode('=', $entry); |
|
886 | + $keys[trim($pair[0])]=$row[trim($pair[1])]; |
|
890 | 887 | } |
891 | 888 | return $keys; |
892 | 889 | } |
893 | 890 | else |
894 | 891 | { |
895 | 892 | $registry=$this->getManager()->getTypeHandlers(); |
896 | - return $property->getPropertyValue($registry,$row); |
|
893 | + return $property->getPropertyValue($registry, $row); |
|
897 | 894 | } |
898 | 895 | } |
899 | 896 | |
@@ -906,30 +903,30 @@ discard block |
||
906 | 903 | */ |
907 | 904 | protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject) |
908 | 905 | { |
909 | - $dataFound = false; |
|
906 | + $dataFound=false; |
|
910 | 907 | foreach($resultMap->getColumns() as $property) |
911 | 908 | { |
912 | - $this->_IsRowDataFound = false; |
|
909 | + $this->_IsRowDataFound=false; |
|
913 | 910 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
914 | - $dataFound = $dataFound || $this->_IsRowDataFound; |
|
911 | + $dataFound=$dataFound || $this->_IsRowDataFound; |
|
915 | 912 | } |
916 | - $this->_IsRowDataFound = $dataFound; |
|
913 | + $this->_IsRowDataFound=$dataFound; |
|
917 | 914 | return $dataFound; |
918 | 915 | } |
919 | 916 | |
920 | 917 | public function __wakeup() |
921 | 918 | { |
922 | 919 | parent::__wakeup(); |
923 | - if (is_null($this->_selectQueue)) $this->_selectQueue = array(); |
|
920 | + if(is_null($this->_selectQueue)) $this->_selectQueue=array(); |
|
924 | 921 | } |
925 | 922 | |
926 | 923 | public function __sleep() |
927 | 924 | { |
928 | - $exprops = array(); $cn = __CLASS__; |
|
929 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
930 | - if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; |
|
931 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
932 | - return array_diff(parent::__sleep(),$exprops); |
|
925 | + $exprops=array(); $cn=__CLASS__; |
|
926 | + if(!count($this->_selectQueue)) $exprops[]="\0$cn\0_selectQueue"; |
|
927 | + if(is_null($this->_groupBy)) $exprops[]="\0$cn\0_groupBy"; |
|
928 | + if(!$this->_IsRowDataFound) $exprops[]="\0$cn\0_IsRowDataFound"; |
|
929 | + return array_diff(parent::__sleep(), $exprops); |
|
933 | 930 | } |
934 | 931 | } |
935 | 932 | |
@@ -948,20 +945,20 @@ discard block |
||
948 | 945 | private $_keys=null; |
949 | 946 | private $_method=TMappedStatement::QUERY_FOR_LIST; |
950 | 947 | |
951 | - public function getStatement(){ return $this->_statement; } |
|
952 | - public function setStatement($value){ $this->_statement = $value; } |
|
948 | + public function getStatement() { return $this->_statement; } |
|
949 | + public function setStatement($value) { $this->_statement=$value; } |
|
953 | 950 | |
954 | - public function getResultProperty(){ return $this->_property; } |
|
955 | - public function setResultProperty($value){ $this->_property = $value; } |
|
951 | + public function getResultProperty() { return $this->_property; } |
|
952 | + public function setResultProperty($value) { $this->_property=$value; } |
|
956 | 953 | |
957 | - public function getResultObject(){ return $this->_resultObject; } |
|
958 | - public function setResultObject($value){ $this->_resultObject = $value; } |
|
954 | + public function getResultObject() { return $this->_resultObject; } |
|
955 | + public function setResultObject($value) { $this->_resultObject=$value; } |
|
959 | 956 | |
960 | - public function getKeys(){ return $this->_keys; } |
|
961 | - public function setKeys($value){ $this->_keys = $value; } |
|
957 | + public function getKeys() { return $this->_keys; } |
|
958 | + public function setKeys($value) { $this->_keys=$value; } |
|
962 | 959 | |
963 | - public function getMethod(){ return $this->_method; } |
|
964 | - public function setMethod($value){ $this->_method = $value; } |
|
960 | + public function getMethod() { return $this->_method; } |
|
961 | + public function setMethod($value) { $this->_method=$value; } |
|
965 | 962 | } |
966 | 963 | |
967 | 964 | /** |
@@ -980,22 +977,22 @@ discard block |
||
980 | 977 | /** |
981 | 978 | * @var array object graph as tree |
982 | 979 | */ |
983 | - private $_tree = array(); |
|
980 | + private $_tree=array(); |
|
984 | 981 | /** |
985 | 982 | * @var array tree node values |
986 | 983 | */ |
987 | - private $_entries = array(); |
|
984 | + private $_entries=array(); |
|
988 | 985 | /** |
989 | 986 | * @var array resulting object collection |
990 | 987 | */ |
991 | - private $_list = array(); |
|
988 | + private $_list=array(); |
|
992 | 989 | |
993 | 990 | /** |
994 | 991 | * @return boolean true if the graph is empty |
995 | 992 | */ |
996 | 993 | public function isEmpty() |
997 | 994 | { |
998 | - return count($this->_entries) == 0; |
|
995 | + return count($this->_entries)==0; |
|
999 | 996 | } |
1000 | 997 | |
1001 | 998 | /** |
@@ -1009,22 +1006,22 @@ discard block |
||
1009 | 1006 | if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null) |
1010 | 1007 | && isset($this->_entries[$node]) && ($this->_entries[$node]!==null)) |
1011 | 1008 | { |
1012 | - $this->_entries[$node] = $object; |
|
1009 | + $this->_entries[$node]=$object; |
|
1013 | 1010 | return; |
1014 | 1011 | } |
1015 | - $this->_entries[$node] = $object; |
|
1012 | + $this->_entries[$node]=$object; |
|
1016 | 1013 | if(empty($parent)) |
1017 | 1014 | { |
1018 | 1015 | if(isset($this->_entries[$node])) |
1019 | 1016 | return; |
1020 | - $this->_tree[$node] = array(); |
|
1017 | + $this->_tree[$node]=array(); |
|
1021 | 1018 | } |
1022 | - $found = $this->addNode($this->_tree, $parent, $node); |
|
1019 | + $found=$this->addNode($this->_tree, $parent, $node); |
|
1023 | 1020 | if(!$found && !empty($parent)) |
1024 | 1021 | { |
1025 | - $this->_tree[$parent] = array(); |
|
1026 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
1027 | - $this->_entries[$parent] = $object; |
|
1022 | + $this->_tree[$parent]=array(); |
|
1023 | + if(!isset($this->_entries[$parent]) || $object!=='') |
|
1024 | + $this->_entries[$parent]=$object; |
|
1028 | 1025 | $this->addNode($this->_tree, $parent, $node); |
1029 | 1026 | } |
1030 | 1027 | } |
@@ -1038,20 +1035,20 @@ discard block |
||
1038 | 1035 | */ |
1039 | 1036 | protected function addNode(&$childs, $parent, $node) |
1040 | 1037 | { |
1041 | - $found = false; |
|
1038 | + $found=false; |
|
1042 | 1039 | reset($childs); |
1043 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
1040 | + for($i=0, $k=count($childs); $i < $k; $i++) |
|
1044 | 1041 | { |
1045 | - $key = key($childs); |
|
1042 | + $key=key($childs); |
|
1046 | 1043 | next($childs); |
1047 | - if($key == $parent) |
|
1044 | + if($key==$parent) |
|
1048 | 1045 | { |
1049 | - $found = true; |
|
1050 | - $childs[$key][$node] = array(); |
|
1046 | + $found=true; |
|
1047 | + $childs[$key][$node]=array(); |
|
1051 | 1048 | } |
1052 | 1049 | else |
1053 | 1050 | { |
1054 | - $found = $found || $this->addNode($childs[$key], $parent, $node); |
|
1051 | + $found=$found || $this->addNode($childs[$key], $parent, $node); |
|
1055 | 1052 | } |
1056 | 1053 | } |
1057 | 1054 | return $found; |
@@ -1073,9 +1070,9 @@ discard block |
||
1073 | 1070 | */ |
1074 | 1071 | protected function hasChildren(&$nodes) |
1075 | 1072 | { |
1076 | - $hasChildren = false; |
|
1073 | + $hasChildren=false; |
|
1077 | 1074 | foreach($nodes as $node) |
1078 | - if(count($node) != 0) |
|
1075 | + if(count($node)!=0) |
|
1079 | 1076 | return true; |
1080 | 1077 | return $hasChildren; |
1081 | 1078 | } |
@@ -1087,14 +1084,14 @@ discard block |
||
1087 | 1084 | */ |
1088 | 1085 | protected function collectChildren($parent, &$nodes) |
1089 | 1086 | { |
1090 | - $noChildren = !$this->hasChildren($nodes); |
|
1091 | - $childs = array(); |
|
1092 | - for(reset($nodes); $key = key($nodes);) |
|
1087 | + $noChildren=!$this->hasChildren($nodes); |
|
1088 | + $childs=array(); |
|
1089 | + for(reset($nodes); $key=key($nodes);) |
|
1093 | 1090 | { |
1094 | 1091 | next($nodes); |
1095 | 1092 | if($noChildren) |
1096 | 1093 | { |
1097 | - $childs[] = $key; |
|
1094 | + $childs[]=$key; |
|
1098 | 1095 | unset($nodes[$key]); |
1099 | 1096 | } |
1100 | 1097 | else |
@@ -1114,17 +1111,17 @@ discard block |
||
1114 | 1111 | if(empty($parent) || empty($this->_entries[$parent])) |
1115 | 1112 | return; |
1116 | 1113 | |
1117 | - $parentObject = $this->_entries[$parent]['object']; |
|
1118 | - $property = $this->_entries[$nodes[0]]['property']; |
|
1114 | + $parentObject=$this->_entries[$parent]['object']; |
|
1115 | + $property=$this->_entries[$nodes[0]]['property']; |
|
1119 | 1116 | |
1120 | - $list = TPropertyAccess::get($parentObject, $property); |
|
1117 | + $list=TPropertyAccess::get($parentObject, $property); |
|
1121 | 1118 | |
1122 | 1119 | foreach($nodes as $node) |
1123 | 1120 | { |
1124 | 1121 | if($list instanceof TList) |
1125 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
1122 | + $parentObject->{$property}[]=$this->_entries[$node]['object']; |
|
1126 | 1123 | else if(is_array($list)) |
1127 | - $list[] = $this->_entries[$node]['object']; |
|
1124 | + $list[]=$this->_entries[$node]['object']; |
|
1128 | 1125 | else |
1129 | 1126 | throw new TSqlMapExecutionException( |
1130 | 1127 | 'sqlmap_property_must_be_list'); |
@@ -1133,8 +1130,8 @@ discard block |
||
1133 | 1130 | if(is_array($list)) |
1134 | 1131 | TPropertyAccess::set($parentObject, $property, $list); |
1135 | 1132 | |
1136 | - if($this->_entries[$parent]['property'] === null) |
|
1137 | - $this->_list[] = $parentObject; |
|
1133 | + if($this->_entries[$parent]['property']===null) |
|
1134 | + $this->_list[]=$parentObject; |
|
1138 | 1135 | } |
1139 | 1136 | |
1140 | 1137 | /** |
@@ -1147,11 +1144,11 @@ discard block |
||
1147 | 1144 | |
1148 | 1145 | public function __sleep() |
1149 | 1146 | { |
1150 | - $exprops = array(); $cn = __CLASS__; |
|
1151 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
1152 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
1153 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
1154 | - return array_diff(parent::__sleep(),$exprops); |
|
1147 | + $exprops=array(); $cn=__CLASS__; |
|
1148 | + if(!count($this->_tree)) $exprops[]="\0$cn\0_tree"; |
|
1149 | + if(!count($this->_entries)) $exprops[]="\0$cn\0_entries"; |
|
1150 | + if(!count($this->_list)) $exprops[]="\0$cn\0_list"; |
|
1151 | + return array_diff(parent::__sleep(), $exprops); |
|
1155 | 1152 | } |
1156 | 1153 | } |
1157 | 1154 | |
@@ -1170,9 +1167,9 @@ discard block |
||
1170 | 1167 | |
1171 | 1168 | public function __construct($result, $parameter, &$list) |
1172 | 1169 | { |
1173 | - $this->_resultObject = $result; |
|
1174 | - $this->_parameterObject = $parameter; |
|
1175 | - $this->_list = &$list; |
|
1170 | + $this->_resultObject=$result; |
|
1171 | + $this->_parameterObject=$parameter; |
|
1172 | + $this->_list=&$list; |
|
1176 | 1173 | } |
1177 | 1174 | |
1178 | 1175 | public function getResult() |
@@ -1207,10 +1204,10 @@ discard block |
||
1207 | 1204 | |
1208 | 1205 | public function __construct($key, $value, $parameter, &$map) |
1209 | 1206 | { |
1210 | - $this->_key = $key; |
|
1211 | - $this->_value = $value; |
|
1212 | - $this->_parameterObject = $parameter; |
|
1213 | - $this->_map = &$map; |
|
1207 | + $this->_key=$key; |
|
1208 | + $this->_value=$value; |
|
1209 | + $this->_parameterObject=$parameter; |
|
1210 | + $this->_map=&$map; |
|
1214 | 1211 | } |
1215 | 1212 | |
1216 | 1213 | public function getKey() |
@@ -22,15 +22,15 @@ |
||
22 | 22 | |
23 | 23 | public function __construct($mappings) |
24 | 24 | { |
25 | - $this->_mappings = $mappings; |
|
25 | + $this->_mappings=$mappings; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function replaceDynamicParameter($sql, $parameter) |
29 | 29 | { |
30 | 30 | foreach($this->_mappings as $property) |
31 | 31 | { |
32 | - $value = TPropertyAccess::get($parameter, $property); |
|
33 | - $sql = preg_replace('/'.TSimpleDynamicParser::DYNAMIC_TOKEN.'/', str_replace('$', '\$', $value), $sql, 1); |
|
32 | + $value=TPropertyAccess::get($parameter, $property); |
|
33 | + $sql=preg_replace('/'.TSimpleDynamicParser::DYNAMIC_TOKEN.'/', str_replace('$', '\$', $value), $sql, 1); |
|
34 | 34 | } |
35 | 35 | return $sql; |
36 | 36 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct(TMappedStatement $statement) |
24 | 24 | { |
25 | - $this->_mappedStatement = $statement; |
|
25 | + $this->_mappedStatement=$statement; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function getID() |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | return $this->_mappedStatement->getManager(); |
41 | 41 | } |
42 | 42 | |
43 | - public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $skip=-1, $max=-1,$delegate=null) |
|
43 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
44 | 44 | { |
45 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
46 | - $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty,$skip, $max)); |
|
47 | - $map = $this->getStatement()->getCache()->get($key); |
|
45 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
46 | + $key=$this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty, $skip, $max)); |
|
47 | + $map=$this->getStatement()->getCache()->get($key); |
|
48 | 48 | if($map===null) |
49 | 49 | { |
50 | - $map = $this->_mappedStatement->runQueryForMap( |
|
51 | - $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
50 | + $map=$this->_mappedStatement->runQueryForMap( |
|
51 | + $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
52 | 52 | $this->getStatement()->getCache()->set($key, $map); |
53 | 53 | } |
54 | 54 | return $map; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | |
67 | 67 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
68 | 68 | { |
69 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
70 | - $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
71 | - $list = $this->getStatement()->getCache()->get($key); |
|
69 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
70 | + $key=$this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
71 | + $list=$this->getStatement()->getCache()->get($key); |
|
72 | 72 | if($list===null) |
73 | 73 | { |
74 | - $list = $this->_mappedStatement->runQueryForList( |
|
74 | + $list=$this->_mappedStatement->runQueryForList( |
|
75 | 75 | $connection, $parameter, $sql, $result, $delegate); |
76 | 76 | $this->getStatement()->getCache()->set($key, $list); |
77 | 77 | } |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | |
81 | 81 | public function executeQueryForObject($connection, $parameter, $result=null) |
82 | 82 | { |
83 | - $sql = $this->createCommand($connection, $parameter); |
|
84 | - $key = $this->getCacheKey(array(clone($sql), $parameter)); |
|
85 | - $object = $this->getStatement()->getCache()->get($key); |
|
83 | + $sql=$this->createCommand($connection, $parameter); |
|
84 | + $key=$this->getCacheKey(array(clone($sql), $parameter)); |
|
85 | + $object=$this->getStatement()->getCache()->get($key); |
|
86 | 86 | if($object===null) |
87 | 87 | { |
88 | - $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
88 | + $object=$this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
89 | 89 | $this->getStatement()->getCache()->set($key, $object); |
90 | 90 | } |
91 | 91 | return $object; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | protected function getCacheKey($object) |
95 | 95 | { |
96 | - $cacheKey = new TSqlMapCacheKey($object); |
|
96 | + $cacheKey=new TSqlMapCacheKey($object); |
|
97 | 97 | return $cacheKey->getHash(); |
98 | 98 | } |
99 | 99 |