@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | default: |
| 192 | 192 | if ($this->isAlphaNum($this->b)) { |
| 193 | 193 | $this->action(1); |
| 194 | - } |
|
| 195 | - else { |
|
| 194 | + } else { |
|
| 196 | 195 | $this->action(2); |
| 197 | 196 | } |
| 198 | 197 | } |
@@ -224,8 +223,7 @@ discard block |
||
| 224 | 223 | default: |
| 225 | 224 | if ($this->isAlphaNum($this->a)) { |
| 226 | 225 | $this->action(1); |
| 227 | - } |
|
| 228 | - else { |
|
| 226 | + } else { |
|
| 229 | 227 | $this->action(3); |
| 230 | 228 | } |
| 231 | 229 | } |
@@ -46,29 +46,29 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | 48 | class JSMin { |
| 49 | - const ORD_LF = 10; |
|
| 50 | - const ORD_SPACE = 32; |
|
| 49 | + const ORD_LF=10; |
|
| 50 | + const ORD_SPACE=32; |
|
| 51 | 51 | |
| 52 | - protected $a = ''; |
|
| 53 | - protected $b = ''; |
|
| 54 | - protected $input = ''; |
|
| 55 | - protected $inputIndex = 0; |
|
| 56 | - protected $inputLength = 0; |
|
| 57 | - protected $lookAhead = null; |
|
| 58 | - protected $output = ''; |
|
| 52 | + protected $a=''; |
|
| 53 | + protected $b=''; |
|
| 54 | + protected $input=''; |
|
| 55 | + protected $inputIndex=0; |
|
| 56 | + protected $inputLength=0; |
|
| 57 | + protected $lookAhead=null; |
|
| 58 | + protected $output=''; |
|
| 59 | 59 | |
| 60 | 60 | // -- Public Static Methods -------------------------------------------------- |
| 61 | 61 | |
| 62 | 62 | public static function minify($js) { |
| 63 | - $jsmin = new JSMin($js); |
|
| 63 | + $jsmin=new JSMin($js); |
|
| 64 | 64 | return $jsmin->min(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // -- Public Instance Methods ------------------------------------------------ |
| 68 | 68 | |
| 69 | 69 | public function __construct($input) { |
| 70 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | - $this->inputLength = strlen($this->input); |
|
| 70 | + $this->input=str_replace("\r\n", "\n", $input); |
|
| 71 | + $this->inputLength=strlen($this->input); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
@@ -76,80 +76,80 @@ discard block |
||
| 76 | 76 | protected function action($d) { |
| 77 | 77 | switch($d) { |
| 78 | 78 | case 1: |
| 79 | - $this->output .= $this->a; |
|
| 79 | + $this->output.=$this->a; |
|
| 80 | 80 | |
| 81 | 81 | case 2: |
| 82 | - $this->a = $this->b; |
|
| 82 | + $this->a=$this->b; |
|
| 83 | 83 | |
| 84 | - if ($this->a === "'" || $this->a === '"') { |
|
| 85 | - for (;;) { |
|
| 86 | - $this->output .= $this->a; |
|
| 87 | - $this->a = $this->get(); |
|
| 84 | + if($this->a==="'" || $this->a==='"') { |
|
| 85 | + for(;;) { |
|
| 86 | + $this->output.=$this->a; |
|
| 87 | + $this->a=$this->get(); |
|
| 88 | 88 | |
| 89 | - if ($this->a === $this->b) { |
|
| 89 | + if($this->a===$this->b) { |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 93 | + if(ord($this->a) <= self::ORD_LF) { |
|
| 94 | 94 | throw new JSMinException('Unterminated string literal.'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if ($this->a === '\\') { |
|
| 98 | - $this->output .= $this->a; |
|
| 99 | - $this->a = $this->get(); |
|
| 97 | + if($this->a==='\\') { |
|
| 98 | + $this->output.=$this->a; |
|
| 99 | + $this->a=$this->get(); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | case 3: |
| 105 | - $this->b = $this->next(); |
|
| 105 | + $this->b=$this->next(); |
|
| 106 | 106 | |
| 107 | - if ($this->b === '/' && ( |
|
| 108 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 107 | + if($this->b==='/' && ( |
|
| 108 | + $this->a==='(' || $this->a===',' || $this->a==='=' || |
|
| 109 | + $this->a===':' || $this->a==='[' || $this->a==='!' || |
|
| 110 | + $this->a==='&' || $this->a==='|' || $this->a==='?')) { |
|
| 111 | 111 | |
| 112 | - $this->output .= $this->a . $this->b; |
|
| 112 | + $this->output.=$this->a.$this->b; |
|
| 113 | 113 | |
| 114 | - for (;;) { |
|
| 115 | - $this->a = $this->get(); |
|
| 114 | + for(;;) { |
|
| 115 | + $this->a=$this->get(); |
|
| 116 | 116 | |
| 117 | - if ($this->a === '/') { |
|
| 117 | + if($this->a==='/') { |
|
| 118 | 118 | break; |
| 119 | - } elseif ($this->a === '\\') { |
|
| 120 | - $this->output .= $this->a; |
|
| 121 | - $this->a = $this->get(); |
|
| 122 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 119 | + } elseif($this->a==='\\') { |
|
| 120 | + $this->output.=$this->a; |
|
| 121 | + $this->a=$this->get(); |
|
| 122 | + } elseif(ord($this->a) <= self::ORD_LF) { |
|
| 123 | 123 | throw new JSMinException('Unterminated regular expression '. |
| 124 | 124 | 'literal.'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $this->output .= $this->a; |
|
| 127 | + $this->output.=$this->a; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $this->b = $this->next(); |
|
| 130 | + $this->b=$this->next(); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | protected function get() { |
| 136 | - $c = $this->lookAhead; |
|
| 137 | - $this->lookAhead = null; |
|
| 136 | + $c=$this->lookAhead; |
|
| 137 | + $this->lookAhead=null; |
|
| 138 | 138 | |
| 139 | - if ($c === null) { |
|
| 140 | - if ($this->inputIndex < $this->inputLength) { |
|
| 141 | - $c = $this->input[$this->inputIndex]; |
|
| 142 | - $this->inputIndex += 1; |
|
| 139 | + if($c===null) { |
|
| 140 | + if($this->inputIndex < $this->inputLength) { |
|
| 141 | + $c=$this->input[$this->inputIndex]; |
|
| 142 | + $this->inputIndex+=1; |
|
| 143 | 143 | } else { |
| 144 | - $c = null; |
|
| 144 | + $c=null; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ($c === "\r") { |
|
| 148 | + if($c==="\r") { |
|
| 149 | 149 | return "\n"; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 152 | + if($c===null || $c==="\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | 153 | return $c; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | protected function isAlphaNum($c) { |
| 160 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 160 | + return ord($c) > 126 || $c==='\\' || preg_match('/^[\w\$]$/', $c)===1; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function min() { |
| 164 | - $this->a = "\n"; |
|
| 164 | + $this->a="\n"; |
|
| 165 | 165 | $this->action(3); |
| 166 | 166 | |
| 167 | - while ($this->a !== null) { |
|
| 168 | - switch ($this->a) { |
|
| 167 | + while($this->a!==null) { |
|
| 168 | + switch($this->a) { |
|
| 169 | 169 | case ' ': |
| 170 | - if ($this->isAlphaNum($this->b)) { |
|
| 170 | + if($this->isAlphaNum($this->b)) { |
|
| 171 | 171 | $this->action(1); |
| 172 | 172 | } else { |
| 173 | 173 | $this->action(2); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | break; |
| 176 | 176 | |
| 177 | 177 | case "\n": |
| 178 | - switch ($this->b) { |
|
| 178 | + switch($this->b) { |
|
| 179 | 179 | case '{': |
| 180 | 180 | case '[': |
| 181 | 181 | case '(': |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | break; |
| 190 | 190 | |
| 191 | 191 | default: |
| 192 | - if ($this->isAlphaNum($this->b)) { |
|
| 192 | + if($this->isAlphaNum($this->b)) { |
|
| 193 | 193 | $this->action(1); |
| 194 | 194 | } |
| 195 | 195 | else { |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | break; |
| 200 | 200 | |
| 201 | 201 | default: |
| 202 | - switch ($this->b) { |
|
| 202 | + switch($this->b) { |
|
| 203 | 203 | case ' ': |
| 204 | - if ($this->isAlphaNum($this->a)) { |
|
| 204 | + if($this->isAlphaNum($this->a)) { |
|
| 205 | 205 | $this->action(1); |
| 206 | 206 | break; |
| 207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | break; |
| 211 | 211 | |
| 212 | 212 | case "\n": |
| 213 | - switch ($this->a) { |
|
| 213 | + switch($this->a) { |
|
| 214 | 214 | case '}': |
| 215 | 215 | case ']': |
| 216 | 216 | case ')': |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | break; |
| 223 | 223 | |
| 224 | 224 | default: |
| 225 | - if ($this->isAlphaNum($this->a)) { |
|
| 225 | + if($this->isAlphaNum($this->a)) { |
|
| 226 | 226 | $this->action(1); |
| 227 | 227 | } |
| 228 | 228 | else { |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | protected function next() { |
| 245 | - $c = $this->get(); |
|
| 245 | + $c=$this->get(); |
|
| 246 | 246 | |
| 247 | - if ($c === '/') { |
|
| 247 | + if($c==='/') { |
|
| 248 | 248 | switch($this->peek()) { |
| 249 | 249 | case '/': |
| 250 | - for (;;) { |
|
| 251 | - $c = $this->get(); |
|
| 250 | + for(;;) { |
|
| 251 | + $c=$this->get(); |
|
| 252 | 252 | |
| 253 | - if (ord($c) <= self::ORD_LF) { |
|
| 253 | + if(ord($c) <= self::ORD_LF) { |
|
| 254 | 254 | return $c; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | case '*': |
| 259 | 259 | $this->get(); |
| 260 | 260 | |
| 261 | - for (;;) { |
|
| 261 | + for(;;) { |
|
| 262 | 262 | switch($this->get()) { |
| 263 | 263 | case '*': |
| 264 | - if ($this->peek() === '/') { |
|
| 264 | + if($this->peek()==='/') { |
|
| 265 | 265 | $this->get(); |
| 266 | 266 | return ' '; |
| 267 | 267 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | protected function peek() { |
| 284 | - $this->lookAhead = $this->get(); |
|
| 284 | + $this->lookAhead=$this->get(); |
|
| 285 | 285 | return $this->lookAhead; |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -129,28 +129,24 @@ |
||
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | 131 | $this->_nextPageList = null; |
| 132 | - } |
|
| 133 | - else |
|
| 132 | + } else |
|
| 134 | 133 | { |
| 135 | 134 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | 135 | $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
| 137 | 136 | } |
| 138 | - } |
|
| 139 | - else |
|
| 137 | + } else |
|
| 140 | 138 | { |
| 141 | 139 | if($total <= $pageSize) |
| 142 | 140 | { |
| 143 | 141 | $this->_prevPageList = array_slice($data, 0, $total); |
| 144 | 142 | $param->setData(array()); |
| 145 | 143 | $this->_nextPageList = null; |
| 146 | - } |
|
| 147 | - else if($total <= $pageSize*2) |
|
| 144 | + } else if($total <= $pageSize*2) |
|
| 148 | 145 | { |
| 149 | 146 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 150 | 147 | $param->setData(array_slice($data, $pageSize, $total)); |
| 151 | 148 | $this->_nextPageList = null; |
| 152 | - } |
|
| 153 | - else |
|
| 149 | + } else |
|
| 154 | 150 | { |
| 155 | 151 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 156 | 152 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | 43 | */ |
| 44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
| 44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate=null, $page=0) |
|
| 45 | 45 | { |
| 46 | 46 | parent::__construct(); |
| 47 | 47 | parent::setCustomPaging(true); |
| 48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
| 48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
| 49 | 49 | $this->_delegate=$delegate; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function initialize($statement, $parameter, $pageSize, $page) |
| 60 | 60 | { |
| 61 | - $this->_statement = $statement; |
|
| 62 | - $this->_parameter = $parameter; |
|
| 61 | + $this->_statement=$statement; |
|
| 62 | + $this->_parameter=$parameter; |
|
| 63 | 63 | $this->setPageSize($pageSize); |
| 64 | 64 | $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); |
| 65 | 65 | $this->gotoPage($page); |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function fetchDataFromStatement($sender, $param) |
| 82 | 82 | { |
| 83 | - $limit = $this->getOffsetAndLimit($param); |
|
| 84 | - $connection = $this->_statement->getManager()->getDbConnection(); |
|
| 85 | - $data = $this->_statement->executeQueryForList($connection, |
|
| 83 | + $limit=$this->getOffsetAndLimit($param); |
|
| 84 | + $connection=$this->_statement->getManager()->getDbConnection(); |
|
| 85 | + $data=$this->_statement->executeQueryForList($connection, |
|
| 86 | 86 | $this->_parameter, null, $limit[0], $limit[1], $this->_delegate); |
| 87 | 87 | $this->populateData($param, $data); |
| 88 | 88 | } |
@@ -112,49 +112,49 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function populateData($param, $data) |
| 114 | 114 | { |
| 115 | - $total = $data instanceof TList ? $data->getCount() : count($data); |
|
| 116 | - $pageSize = $this->getPageSize(); |
|
| 115 | + $total=$data instanceof TList ? $data->getCount() : count($data); |
|
| 116 | + $pageSize=$this->getPageSize(); |
|
| 117 | 117 | if($total < 1) |
| 118 | 118 | { |
| 119 | 119 | $param->setData($data); |
| 120 | - $this->_prevPageList = null; |
|
| 121 | - $this->_nextPageList = null; |
|
| 120 | + $this->_prevPageList=null; |
|
| 121 | + $this->_nextPageList=null; |
|
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if($param->getNewPageIndex() < 1) |
| 126 | 126 | { |
| 127 | - $this->_prevPageList = null; |
|
| 127 | + $this->_prevPageList=null; |
|
| 128 | 128 | if($total <= $pageSize) |
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | - $this->_nextPageList = null; |
|
| 131 | + $this->_nextPageList=null; |
|
| 132 | 132 | } |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
| 136 | + $this->_nextPageList=array_slice($data, $pageSize - 1, $total); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | else |
| 140 | 140 | { |
| 141 | 141 | if($total <= $pageSize) |
| 142 | 142 | { |
| 143 | - $this->_prevPageList = array_slice($data, 0, $total); |
|
| 143 | + $this->_prevPageList=array_slice($data, 0, $total); |
|
| 144 | 144 | $param->setData(array()); |
| 145 | - $this->_nextPageList = null; |
|
| 145 | + $this->_nextPageList=null; |
|
| 146 | 146 | } |
| 147 | - else if($total <= $pageSize*2) |
|
| 147 | + else if($total <= $pageSize * 2) |
|
| 148 | 148 | { |
| 149 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
| 149 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
| 150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
| 151 | - $this->_nextPageList = null; |
|
| 151 | + $this->_nextPageList=null; |
|
| 152 | 152 | } |
| 153 | 153 | else |
| 154 | 154 | { |
| 155 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
| 155 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
| 156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
| 157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
| 157 | + $this->_nextPageList=array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function getOffsetAndLimit($param) |
| 168 | 168 | { |
| 169 | - $index = $param->getNewPageIndex(); |
|
| 170 | - $pageSize = $this->getPageSize(); |
|
| 171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
| 169 | + $index=$param->getNewPageIndex(); |
|
| 170 | + $pageSize=$this->getPageSize(); |
|
| 171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -416,8 +416,7 @@ |
||
| 416 | 416 | { |
| 417 | 417 | $useArgs = !is_array($parameters) && is_array($args); |
| 418 | 418 | return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
| 419 | - } |
|
| 420 | - else if($criteria instanceof TSqlCriteria) |
|
| 419 | + } else if($criteria instanceof TSqlCriteria) |
|
| 421 | 420 | return $criteria; |
| 422 | 421 | else |
| 423 | 422 | throw new TDbException('dbtablegateway_invalid_criteria'); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string|TDbTableInfo table or view name or table information. |
| 88 | 88 | * @param TDbConnection database connection. |
| 89 | 89 | */ |
| 90 | - public function __construct($table,$connection) |
|
| 90 | + public function __construct($table, $connection) |
|
| 91 | 91 | { |
| 92 | 92 | $this->_connection=$connection; |
| 93 | 93 | if(is_string($table)) |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function setTableInfo($tableInfo) |
| 105 | 105 | { |
| 106 | - $builder = $tableInfo->createCommandBuilder($this->getDbConnection()); |
|
| 106 | + $builder=$tableInfo->createCommandBuilder($this->getDbConnection()); |
|
| 107 | 107 | $this->initCommandBuilder($builder); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | protected function setTableName($tableName) |
| 115 | 115 | { |
| 116 | 116 | Prado::using('System.Data.Common.TDbMetaData'); |
| 117 | - $meta = TDbMetaData::getInstance($this->getDbConnection()); |
|
| 117 | + $meta=TDbMetaData::getInstance($this->getDbConnection()); |
|
| 118 | 118 | $this->initCommandBuilder($meta->createCommandBuilder($tableName)); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | protected function initCommandBuilder($builder) |
| 135 | 135 | { |
| 136 | - $this->_command = new TDataGatewayCommand($builder); |
|
| 137 | - $this->_command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
| 138 | - $this->_command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
| 136 | + $this->_command=new TDataGatewayCommand($builder); |
|
| 137 | + $this->_command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
| 138 | + $this->_command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function findBySql($sql, $parameters=array()) |
| 191 | 191 | { |
| 192 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 193 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
| 192 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 193 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
| 194 | 194 | return $this->getCommand()->findBySql($criteria); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function findAllBySql($sql, $parameters=array()) |
| 204 | 204 | { |
| 205 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 206 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
| 205 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 206 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
| 207 | 207 | return $this->getCommand()->findAllBySql($criteria); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function find($criteria, $parameters=array()) |
| 228 | 228 | { |
| 229 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 230 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
| 229 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 230 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
| 231 | 231 | return $this->getCommand()->find($criteria); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function findAll($criteria=null, $parameters=array()) |
| 241 | 241 | { |
| 242 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 242 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 243 | 243 | if($criteria!==null) |
| 244 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
| 244 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
| 245 | 245 | return $this->getCommand()->findAll($criteria); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | public function findByPk($keys) |
| 261 | 261 | { |
| 262 | 262 | if(func_num_args() > 1) |
| 263 | - $keys = func_get_args(); |
|
| 263 | + $keys=func_get_args(); |
|
| 264 | 264 | return $this->getCommand()->findByPk($keys); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | public function findAllByPks($keys) |
| 285 | 285 | { |
| 286 | 286 | if(func_num_args() > 1) |
| 287 | - $keys = func_get_args(); |
|
| 287 | + $keys=func_get_args(); |
|
| 288 | 288 | return $this->getCommand()->findAllByPk($keys); |
| 289 | 289 | } |
| 290 | 290 | |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public function deleteAll($criteria, $parameters=array()) |
| 303 | 303 | { |
| 304 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 305 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
| 304 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 305 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
| 306 | 306 | return $this->getCommand()->delete($criteria); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | public function deleteByPk($keys) |
| 333 | 333 | { |
| 334 | 334 | if(func_num_args() > 1) |
| 335 | - $keys = func_get_args(); |
|
| 335 | + $keys=func_get_args(); |
|
| 336 | 336 | return $this->getCommand()->deleteByPk($keys); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | public function deleteAllByPks($keys) |
| 343 | 343 | { |
| 344 | 344 | if(func_num_args() > 1) |
| 345 | - $keys = func_get_args(); |
|
| 345 | + $keys=func_get_args(); |
|
| 346 | 346 | return $this->deleteByPk($keys); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -352,11 +352,11 @@ discard block |
||
| 352 | 352 | * @param mixed parameter values. |
| 353 | 353 | * @return int number of records. |
| 354 | 354 | */ |
| 355 | - public function count($criteria=null,$parameters=array()) |
|
| 355 | + public function count($criteria=null, $parameters=array()) |
|
| 356 | 356 | { |
| 357 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
| 357 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
| 358 | 358 | if($criteria!==null) |
| 359 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
| 359 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
| 360 | 360 | return $this->getCommand()->count($criteria); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | public function update($data, $criteria, $parameters=array()) |
| 378 | 378 | { |
| 379 | - $args = func_num_args() > 2 ? array_slice(func_get_args(),2) : null; |
|
| 380 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
| 379 | + $args=func_num_args() > 2 ? array_slice(func_get_args(), 2) : null; |
|
| 380 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
| 381 | 381 | return $this->getCommand()->update($data, $criteria); |
| 382 | 382 | } |
| 383 | 383 | |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | { |
| 415 | 415 | if(is_string($criteria)) |
| 416 | 416 | { |
| 417 | - $useArgs = !is_array($parameters) && is_array($args); |
|
| 418 | - return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
|
| 417 | + $useArgs=!is_array($parameters) && is_array($args); |
|
| 418 | + return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
|
| 419 | 419 | } |
| 420 | 420 | else if($criteria instanceof TSqlCriteria) |
| 421 | 421 | return $criteria; |
@@ -452,21 +452,21 @@ discard block |
||
| 452 | 452 | * @return mixed single record if method name starts with "findBy", 0 or more records |
| 453 | 453 | * if method name starts with "findAllBy" |
| 454 | 454 | */ |
| 455 | - public function __call($method,$args) |
|
| 455 | + public function __call($method, $args) |
|
| 456 | 456 | { |
| 457 | - $delete =false; |
|
| 458 | - if($findOne = substr(strtolower($method),0,6)==='findby') |
|
| 459 | - $condition = $method[6]==='_' ? substr($method,7) : substr($method,6); |
|
| 460 | - else if(substr(strtolower($method),0,9)==='findallby') |
|
| 461 | - $condition = $method[9]==='_' ? substr($method,10) : substr($method,9); |
|
| 462 | - else if($delete = substr(strtolower($method),0,8)==='deleteby') |
|
| 463 | - $condition = $method[8]==='_' ? substr($method,9) : substr($method,8); |
|
| 464 | - else if($delete = substr(strtolower($method),0,11)==='deleteallby') |
|
| 465 | - $condition = $method[11]==='_' ? substr($method,12) : substr($method,11); |
|
| 457 | + $delete=false; |
|
| 458 | + if($findOne=substr(strtolower($method), 0, 6)==='findby') |
|
| 459 | + $condition=$method[6]==='_' ? substr($method, 7) : substr($method, 6); |
|
| 460 | + else if(substr(strtolower($method), 0, 9)==='findallby') |
|
| 461 | + $condition=$method[9]==='_' ? substr($method, 10) : substr($method, 9); |
|
| 462 | + else if($delete=substr(strtolower($method), 0, 8)==='deleteby') |
|
| 463 | + $condition=$method[8]==='_' ? substr($method, 9) : substr($method, 8); |
|
| 464 | + else if($delete=substr(strtolower($method), 0, 11)==='deleteallby') |
|
| 465 | + $condition=$method[11]==='_' ? substr($method, 12) : substr($method, 11); |
|
| 466 | 466 | else |
| 467 | 467 | return null; |
| 468 | 468 | |
| 469 | - $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
| 469 | + $criteria=$this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
| 470 | 470 | if($delete) |
| 471 | 471 | return $this->deleteAll($criteria); |
| 472 | 472 | else |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | case 'datetime': case 'timestamp': |
| 34 | 34 | return $this->createDateTimeControl($container, $column, $record); |
| 35 | 35 | default: |
| 36 | - return $this->createDefaultControl($container,$column, $record); |
|
| 36 | + return $this->createDefaultControl($container, $column, $record); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | case 'time': |
| 51 | 51 | return $this->getTimeValue($container, $column, $record); |
| 52 | 52 | case 'datetime': case 'timestamp': |
| 53 | - return $this->getDateTimeValue($container,$column, $record); |
|
| 53 | + return $this->getDateTimeValue($container, $column, $record); |
|
| 54 | 54 | default: |
| 55 | - return $this->getDefaultControlValue($container,$column, $record); |
|
| 55 | + return $this->getDefaultControlValue($container, $column, $record); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | protected function createDateControl($container, $column, $record) |
| 60 | 60 | { |
| 61 | - $control = parent::createDateControl($container, $column, $record); |
|
| 62 | - $value = $this->getRecordPropertyValue($column, $record); |
|
| 61 | + $control=parent::createDateControl($container, $column, $record); |
|
| 62 | + $value=$this->getRecordPropertyValue($column, $record); |
|
| 63 | 63 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
| 64 | 64 | $control->setTimestamp(intval($value)); |
| 65 | 65 | return $control; |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | protected function createDateTimeControl($container, $column, $record) |
| 69 | 69 | { |
| 70 | - $value = $this->getRecordPropertyValue($column, $record); |
|
| 71 | - $time = parent::createDateTimeControl($container, $column, $record); |
|
| 70 | + $value=$this->getRecordPropertyValue($column, $record); |
|
| 71 | + $time=parent::createDateTimeControl($container, $column, $record); |
|
| 72 | 72 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
| 73 | 73 | { |
| 74 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
| 75 | - $date = $s->getDate(intval($value)); |
|
| 74 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
| 75 | + $date=$s->getDate(intval($value)); |
|
| 76 | 76 | $time[1]->setSelectedValue($date['hours']); |
| 77 | 77 | $time[2]->setSelectedValue($date['minutes']); |
| 78 | 78 | $time[3]->setSelectedValue($date['seconds']); |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | if(preg_match('/timestamp/i', $column->getDbType())) |
| 86 | 86 | { |
| 87 | - $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
| 88 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
| 89 | - $date = $s->getDate($time); |
|
| 90 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
| 91 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
| 92 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
| 93 | - return $s->getTimeStamp($hour,$mins,$secs,$date['mon'],$date['mday'],$date['year']); |
|
| 87 | + $time=$container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
| 88 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
| 89 | + $date=$s->getDate($time); |
|
| 90 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
| 91 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
| 92 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
| 93 | + return $s->getTimeStamp($hour, $mins, $secs, $date['mon'], $date['mday'], $date['year']); |
|
| 94 | 94 | } |
| 95 | 95 | else |
| 96 | 96 | return parent::getDateTimeValue($container, $column, $record); |
@@ -115,8 +115,7 @@ discard block |
||
| 115 | 115 | $columns = $this->getTableInfo()->getColumns(); |
| 116 | 116 | $this->getInputRepeater()->setDataSource($columns); |
| 117 | 117 | $this->getInputRepeater()->dataBind(); |
| 118 | - } |
|
| 119 | - else |
|
| 118 | + } else |
|
| 120 | 119 | { |
| 121 | 120 | if($this->_editRenderer===null) |
| 122 | 121 | $this->createEditRenderer($record, $classPath); |
@@ -140,8 +139,7 @@ discard block |
||
| 140 | 139 | $index = $this->getControls()->remove($this->getInputRepeater()); |
| 141 | 140 | $this->getControls()->insertAt($index,$this->_editRenderer); |
| 142 | 141 | $this->_editRenderer->setData($record); |
| 143 | - } |
|
| 144 | - else |
|
| 142 | + } else |
|
| 145 | 143 | { |
| 146 | 144 | throw new TConfigurationException( |
| 147 | 145 | 'scaffold_invalid_edit_renderer', $this->getID(), get_class($record)); |
@@ -204,15 +202,13 @@ discard block |
||
| 204 | 202 | $column = $table->getColumn($item->getCustomData()); |
| 205 | 203 | $builder->loadScaffoldInput($this, $item, $column, $record); |
| 206 | 204 | } |
| 207 | - } |
|
| 208 | - else |
|
| 205 | + } else |
|
| 209 | 206 | { |
| 210 | 207 | $this->_editRenderer->updateRecord($record); |
| 211 | 208 | } |
| 212 | 209 | $record->save(); |
| 213 | 210 | return true; |
| 214 | - } |
|
| 215 | - else if($this->_editRenderer!==null) |
|
| 211 | + } else if($this->_editRenderer!==null) |
|
| 216 | 212 | { |
| 217 | 213 | //preserve the form data. |
| 218 | 214 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function setRecordPk($value) |
| 84 | 84 | { |
| 85 | 85 | $this->clearRecordObject(); |
| 86 | - $val = TPropertyValue::ensureArray($value); |
|
| 86 | + $val=TPropertyValue::ensureArray($value); |
|
| 87 | 87 | $this->setViewState('PK', count($val) > 0 ? $val : null); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function initializeEditForm() |
| 110 | 110 | { |
| 111 | - $record = $this->getCurrentRecord(); |
|
| 112 | - $classPath = $this->getEditRenderer(); |
|
| 113 | - if($classPath === '') |
|
| 111 | + $record=$this->getCurrentRecord(); |
|
| 112 | + $classPath=$this->getEditRenderer(); |
|
| 113 | + if($classPath==='') |
|
| 114 | 114 | { |
| 115 | - $columns = $this->getTableInfo()->getColumns(); |
|
| 115 | + $columns=$this->getTableInfo()->getColumns(); |
|
| 116 | 116 | $this->getInputRepeater()->setDataSource($columns); |
| 117 | 117 | $this->getInputRepeater()->dataBind(); |
| 118 | 118 | } |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function createEditRenderer($record, $classPath) |
| 136 | 136 | { |
| 137 | - $this->_editRenderer = Prado::createComponent($classPath); |
|
| 137 | + $this->_editRenderer=Prado::createComponent($classPath); |
|
| 138 | 138 | if($this->_editRenderer instanceof IScaffoldEditRenderer) |
| 139 | 139 | { |
| 140 | - $index = $this->getControls()->remove($this->getInputRepeater()); |
|
| 141 | - $this->getControls()->insertAt($index,$this->_editRenderer); |
|
| 140 | + $index=$this->getControls()->remove($this->getInputRepeater()); |
|
| 141 | + $this->getControls()->insertAt($index, $this->_editRenderer); |
|
| 142 | 142 | $this->_editRenderer->setData($record); |
| 143 | 143 | } |
| 144 | 144 | else |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function createRepeaterEditItem($sender, $param) |
| 155 | 155 | { |
| 156 | - $type = $param->getItem()->getItemType(); |
|
| 156 | + $type=$param->getItem()->getItemType(); |
|
| 157 | 157 | if($type==TListItemType::Item || $type==TListItemType::AlternatingItem) |
| 158 | 158 | { |
| 159 | - $item = $param->getItem(); |
|
| 160 | - $column = $item->getDataItem(); |
|
| 159 | + $item=$param->getItem(); |
|
| 160 | + $column=$item->getDataItem(); |
|
| 161 | 161 | if($column===null) |
| 162 | 162 | return; |
| 163 | 163 | |
| 164 | - $record = $this->getCurrentRecord(); |
|
| 165 | - $builder = $this->getScaffoldInputBuilder($record); |
|
| 164 | + $record=$this->getCurrentRecord(); |
|
| 165 | + $builder=$this->getScaffoldInputBuilder($record); |
|
| 166 | 166 | $builder->createScaffoldInput($this, $item, $column, $record); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | if($this->getPage()->getIsValid()) |
| 196 | 196 | { |
| 197 | - $record = $this->getCurrentRecord(); |
|
| 197 | + $record=$this->getCurrentRecord(); |
|
| 198 | 198 | if($this->_editRenderer===null) |
| 199 | 199 | { |
| 200 | - $table = $this->getTableInfo(); |
|
| 201 | - $builder = $this->getScaffoldInputBuilder($record); |
|
| 200 | + $table=$this->getTableInfo(); |
|
| 201 | + $builder=$this->getScaffoldInputBuilder($record); |
|
| 202 | 202 | foreach($this->getInputRepeater()->getItems() as $item) |
| 203 | 203 | { |
| 204 | - $column = $table->getColumn($item->getCustomData()); |
|
| 204 | + $column=$table->getColumn($item->getCustomData()); |
|
| 205 | 205 | $builder->loadScaffoldInput($this, $item, $column, $record); |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | protected function getScaffoldInputBuilder($record) |
| 266 | 266 | { |
| 267 | 267 | static $_builders=array(); |
| 268 | - $class = get_class($record); |
|
| 268 | + $class=get_class($record); |
|
| 269 | 269 | if(!isset($_builders[$class])) |
| 270 | 270 | { |
| 271 | 271 | Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputBase'); |
| 272 | - $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
|
| 272 | + $_builders[$class]=TScaffoldInputBase::createInputBuilder($record); |
|
| 273 | 273 | } |
| 274 | 274 | return $_builders[$class]; |
| 275 | 275 | } |
@@ -67,16 +67,14 @@ |
||
| 67 | 67 | throw new TActiveRecordException('ar_invalid_tablename_property', |
| 68 | 68 | get_class($record),self::TABLE_CONST); |
| 69 | 69 | return $value; |
| 70 | - } |
|
| 71 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
| 70 | + } elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
| 72 | 71 | { |
| 73 | 72 | $value = $record->{self::TABLE_METHOD}(); |
| 74 | 73 | if(empty($value)) |
| 75 | 74 | throw new TActiveRecordException('ar_invalid_tablename_method', |
| 76 | 75 | get_class($record),self::TABLE_METHOD); |
| 77 | 76 | return $value; |
| 78 | - } |
|
| 79 | - else |
|
| 77 | + } else |
|
| 80 | 78 | return strtolower(get_class($record)); |
| 81 | 79 | } |
| 82 | 80 | |
@@ -59,21 +59,21 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | protected function getRecordTableName(TActiveRecord $record) |
| 61 | 61 | { |
| 62 | - $class = new ReflectionClass($record); |
|
| 62 | + $class=new ReflectionClass($record); |
|
| 63 | 63 | if($class->hasConstant(self::TABLE_CONST)) |
| 64 | 64 | { |
| 65 | - $value = $class->getConstant(self::TABLE_CONST); |
|
| 65 | + $value=$class->getConstant(self::TABLE_CONST); |
|
| 66 | 66 | if(empty($value)) |
| 67 | 67 | throw new TActiveRecordException('ar_invalid_tablename_property', |
| 68 | - get_class($record),self::TABLE_CONST); |
|
| 68 | + get_class($record), self::TABLE_CONST); |
|
| 69 | 69 | return $value; |
| 70 | 70 | } |
| 71 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
| 71 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
| 72 | 72 | { |
| 73 | - $value = $record->{self::TABLE_METHOD}(); |
|
| 73 | + $value=$record->{self::TABLE_METHOD}(); |
|
| 74 | 74 | if(empty($value)) |
| 75 | 75 | throw new TActiveRecordException('ar_invalid_tablename_method', |
| 76 | - get_class($record),self::TABLE_METHOD); |
|
| 76 | + get_class($record), self::TABLE_METHOD); |
|
| 77 | 77 | return $value; |
| 78 | 78 | } |
| 79 | 79 | else |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function getRecordTableInfo(TActiveRecord $record) |
| 89 | 89 | { |
| 90 | - $tableName = $this->getRecordTableName($record); |
|
| 90 | + $tableName=$this->getRecordTableName($record); |
|
| 91 | 91 | return $this->getTableInfo($record->getDbConnection(), $tableName); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function getTableInfo(TDbConnection $connection, $tableName) |
| 101 | 101 | { |
| 102 | - $connStr = $connection->getConnectionString(); |
|
| 103 | - $key = $connStr.$tableName; |
|
| 102 | + $connStr=$connection->getConnectionString(); |
|
| 103 | + $key=$connStr.$tableName; |
|
| 104 | 104 | if(!isset($this->_tables[$key])) |
| 105 | 105 | { |
| 106 | 106 | //call this first to ensure that unserializing the cache |
@@ -108,19 +108,19 @@ discard block |
||
| 108 | 108 | if(!isset($this->_meta[$connStr])) |
| 109 | 109 | { |
| 110 | 110 | Prado::using('System.Data.Common.TDbMetaData'); |
| 111 | - $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
|
| 111 | + $this->_meta[$connStr]=TDbMetaData::getInstance($connection); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $tableInfo = null; |
|
| 114 | + $tableInfo=null; |
|
| 115 | 115 | if(($cache=$this->getManager()->getCache())!==null) |
| 116 | - $tableInfo = $cache->get($key); |
|
| 116 | + $tableInfo=$cache->get($key); |
|
| 117 | 117 | if(empty($tableInfo)) |
| 118 | 118 | { |
| 119 | - $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
|
| 119 | + $tableInfo=$this->_meta[$connStr]->getTableInfo($tableName); |
|
| 120 | 120 | if($cache!==null) |
| 121 | 121 | $cache->set($key, $tableInfo); |
| 122 | 122 | } |
| 123 | - $this->_tables[$key] = $tableInfo; |
|
| 123 | + $this->_tables[$key]=$tableInfo; |
|
| 124 | 124 | } |
| 125 | 125 | return $this->_tables[$key]; |
| 126 | 126 | } |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function getCommand(TActiveRecord $record) |
| 133 | 133 | { |
| 134 | - $conn = $record->getDbConnection(); |
|
| 135 | - $connStr = $conn->getConnectionString(); |
|
| 136 | - $tableInfo = $this->getRecordTableInfo($record); |
|
| 134 | + $conn=$record->getDbConnection(); |
|
| 135 | + $connStr=$conn->getConnectionString(); |
|
| 136 | + $tableInfo=$this->getRecordTableInfo($record); |
|
| 137 | 137 | if(!isset($this->_commandBuilders[$connStr])) |
| 138 | 138 | { |
| 139 | - $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
|
| 139 | + $builder=$tableInfo->createCommandBuilder($record->getDbConnection()); |
|
| 140 | 140 | Prado::using('System.Data.DataGateway.TDataGatewayCommand'); |
| 141 | - $command = new TDataGatewayCommand($builder); |
|
| 142 | - $command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
| 143 | - $command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
| 144 | - $this->_commandBuilders[$connStr] = $command; |
|
| 141 | + $command=new TDataGatewayCommand($builder); |
|
| 142 | + $command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
| 143 | + $command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
| 144 | + $this->_commandBuilders[$connStr]=$command; |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | * @param array primary name value pairs |
| 192 | 192 | * @return array record data |
| 193 | 193 | */ |
| 194 | - public function findRecordByPK(TActiveRecord $record,$keys) |
|
| 194 | + public function findRecordByPK(TActiveRecord $record, $keys) |
|
| 195 | 195 | { |
| 196 | - $command = $this->getCommand($record); |
|
| 196 | + $command=$this->getCommand($record); |
|
| 197 | 197 | return $command->findByPk($keys); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) |
| 221 | 221 | { |
| 222 | - $command = $this->getCommand($record); |
|
| 222 | + $command=$this->getCommand($record); |
|
| 223 | 223 | return $iterator ? $command->findAll($criteria) : $command->find($criteria); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values) |
| 249 | 249 | { |
| 250 | - return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values); |
|
| 250 | + return $this->getCommand($record)->findAllByIndex($criteria, $fields, $values); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | public function insert(TActiveRecord $record) |
| 270 | 270 | { |
| 271 | 271 | //$this->updateAssociatedRecords($record,true); |
| 272 | - $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
|
| 272 | + $result=$this->getCommand($record)->insert($this->getInsertValues($record)); |
|
| 273 | 273 | if($result) |
| 274 | 274 | $this->updatePostInsert($record); |
| 275 | 275 | //$this->updateAssociatedRecords($record); |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | protected function updatePostInsert($record) |
| 284 | 284 | { |
| 285 | - $command = $this->getCommand($record); |
|
| 286 | - $tableInfo = $command->getTableInfo(); |
|
| 285 | + $command=$this->getCommand($record); |
|
| 286 | + $tableInfo=$command->getTableInfo(); |
|
| 287 | 287 | foreach($tableInfo->getColumns() as $name => $column) |
| 288 | 288 | { |
| 289 | 289 | if($column->hasSequence()) |
| 290 | - $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName())); |
|
| 290 | + $record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName())); |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
@@ -298,20 +298,20 @@ discard block |
||
| 298 | 298 | protected function getInsertValues(TActiveRecord $record) |
| 299 | 299 | { |
| 300 | 300 | $values=array(); |
| 301 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
| 301 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
| 302 | 302 | foreach($tableInfo->getColumns() as $name=>$column) |
| 303 | 303 | { |
| 304 | 304 | if($column->getIsExcluded()) |
| 305 | 305 | continue; |
| 306 | - $value = $record->getColumnValue($name); |
|
| 307 | - if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
| 306 | + $value=$record->getColumnValue($name); |
|
| 307 | + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
| 308 | 308 | { |
| 309 | 309 | throw new TActiveRecordException( |
| 310 | 310 | 'ar_value_must_not_be_null', get_class($record), |
| 311 | 311 | $tableInfo->getTableFullName(), $name); |
| 312 | 312 | } |
| 313 | 313 | if($value!==null) |
| 314 | - $values[$name] = $value; |
|
| 314 | + $values[$name]=$value; |
|
| 315 | 315 | } |
| 316 | 316 | return $values; |
| 317 | 317 | } |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | public function update(TActiveRecord $record) |
| 325 | 325 | { |
| 326 | 326 | //$this->updateAssociatedRecords($record,true); |
| 327 | - list($data, $keys) = $this->getUpdateValues($record); |
|
| 328 | - $result = $this->getCommand($record)->updateByPk($data, $keys); |
|
| 327 | + list($data, $keys)=$this->getUpdateValues($record); |
|
| 328 | + $result=$this->getCommand($record)->updateByPk($data, $keys); |
|
| 329 | 329 | //$this->updateAssociatedRecords($record); |
| 330 | 330 | return $result; |
| 331 | 331 | } |
@@ -333,30 +333,30 @@ discard block |
||
| 333 | 333 | protected function getUpdateValues(TActiveRecord $record) |
| 334 | 334 | { |
| 335 | 335 | $values=array(); |
| 336 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
| 336 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
| 337 | 337 | $primary=array(); |
| 338 | 338 | foreach($tableInfo->getColumns() as $name=>$column) |
| 339 | 339 | { |
| 340 | 340 | if($column->getIsExcluded()) |
| 341 | 341 | continue; |
| 342 | - $value = $record->getColumnValue($name); |
|
| 343 | - if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
| 342 | + $value=$record->getColumnValue($name); |
|
| 343 | + if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
| 344 | 344 | { |
| 345 | 345 | throw new TActiveRecordException( |
| 346 | 346 | 'ar_value_must_not_be_null', get_class($record), |
| 347 | 347 | $tableInfo->getTableFullName(), $name); |
| 348 | 348 | } |
| 349 | 349 | if($column->getIsPrimaryKey()) |
| 350 | - $primary[$name] = $value; |
|
| 350 | + $primary[$name]=$value; |
|
| 351 | 351 | else |
| 352 | - $values[$name] = $value; |
|
| 352 | + $values[$name]=$value; |
|
| 353 | 353 | } |
| 354 | - return array($values,$primary); |
|
| 354 | + return array($values, $primary); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false) |
|
| 357 | + protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false) |
|
| 358 | 358 | { |
| 359 | - $context = new TActiveRecordRelationContext($record); |
|
| 359 | + $context=new TActiveRecordRelationContext($record); |
|
| 360 | 360 | return $context->updateAssociatedRecords($updateBelongsTo); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -372,12 +372,12 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | protected function getPrimaryKeyValues(TActiveRecord $record) |
| 374 | 374 | { |
| 375 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
| 375 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
| 376 | 376 | $primary=array(); |
| 377 | 377 | foreach($tableInfo->getColumns() as $name=>$column) |
| 378 | 378 | { |
| 379 | 379 | if($column->getIsPrimaryKey()) |
| 380 | - $primary[$name] = $record->getColumnValue($name); |
|
| 380 | + $primary[$name]=$record->getColumnValue($name); |
|
| 381 | 381 | } |
| 382 | 382 | return $primary; |
| 383 | 383 | } |
@@ -410,12 +410,12 @@ discard block |
||
| 410 | 410 | * @param TActiveRecord active record |
| 411 | 411 | * @param TActiveRecordCriteria data for the command. |
| 412 | 412 | */ |
| 413 | - protected function raiseCommandEvent($event,$command,$record,$criteria) |
|
| 413 | + protected function raiseCommandEvent($event, $command, $record, $criteria) |
|
| 414 | 414 | { |
| 415 | 415 | if(!($criteria instanceof TSqlCriteria)) |
| 416 | - $criteria = new TActiveRecordCriteria(null,$criteria); |
|
| 417 | - $param = new TActiveRecordEventParameter($command,$record,$criteria); |
|
| 418 | - $manager = $record->getRecordManager(); |
|
| 416 | + $criteria=new TActiveRecordCriteria(null, $criteria); |
|
| 417 | + $param=new TActiveRecordEventParameter($command, $record, $criteria); |
|
| 418 | + $manager=$record->getRecordManager(); |
|
| 419 | 419 | $manager->{$event}($param); |
| 420 | 420 | $record->{$event}($param); |
| 421 | 421 | } |
@@ -189,8 +189,7 @@ discard block |
||
| 189 | 189 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 190 | 190 | $this->_active=true; |
| 191 | 191 | $this->setConnectionCharset(); |
| 192 | - } |
|
| 193 | - catch(PDOException $e) |
|
| 192 | + } catch(PDOException $e) |
|
| 194 | 193 | { |
| 195 | 194 | throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
| 196 | 195 | } |
@@ -343,8 +342,7 @@ discard block |
||
| 343 | 342 | { |
| 344 | 343 | $this->_pdo->beginTransaction(); |
| 345 | 344 | return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this); |
| 346 | - } |
|
| 347 | - else |
|
| 345 | + } else |
|
| 348 | 346 | throw new TDbException('dbconnection_connection_inactive'); |
| 349 | 347 | } |
| 350 | 348 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @since 3.1.7 |
| 87 | 87 | */ |
| 88 | - const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction'; |
|
| 88 | + const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction'; |
|
| 89 | 89 | |
| 90 | 90 | private $_dsn=''; |
| 91 | 91 | private $_username=''; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @var TDbMetaData |
| 101 | 101 | */ |
| 102 | - private $_dbMeta = null; |
|
| 102 | + private $_dbMeta=null; |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @var string |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server |
| 121 | 121 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 122 | 122 | */ |
| 123 | - public function __construct($dsn='',$username='',$password='', $charset='') |
|
| 123 | + public function __construct($dsn='', $username='', $password='', $charset='') |
|
| 124 | 124 | { |
| 125 | 125 | $this->_dsn=$dsn; |
| 126 | 126 | $this->_username=$username; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function __sleep() |
| 135 | 135 | { |
| 136 | 136 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
| 137 | - return array_diff(parent::__sleep(),array("\0TDbConnection\0_pdo","\0TDbConnection\0_active")); |
|
| 137 | + return array_diff(parent::__sleep(), array("\0TDbConnection\0_pdo", "\0TDbConnection\0_active")); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | try |
| 183 | 183 | { |
| 184 | - $this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(), |
|
| 185 | - $this->getPassword(),$this->_attributes); |
|
| 184 | + $this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(), |
|
| 185 | + $this->getPassword(), $this->_attributes); |
|
| 186 | 186 | // This attribute is only useful for PDO::MySql driver. |
| 187 | 187 | // Ignore the warning if a driver doesn't understand this. |
| 188 | 188 | @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | catch(PDOException $e) |
| 194 | 194 | { |
| 195 | - throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
|
| 195 | + throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function setConnectionCharset() |
| 216 | 216 | { |
| 217 | - if ($this->_charset === '' || $this->_active === false) |
|
| 217 | + if($this->_charset==='' || $this->_active===false) |
|
| 218 | 218 | return; |
| 219 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 219 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 220 | 220 | { |
| 221 | 221 | case 'mysql': |
| 222 | 222 | case 'sqlite': |
| 223 | - $stmt = $this->_pdo->prepare('SET NAMES ?'); |
|
| 223 | + $stmt=$this->_pdo->prepare('SET NAMES ?'); |
|
| 224 | 224 | break; |
| 225 | 225 | case 'pgsql': |
| 226 | - $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 226 | + $stmt=$this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 227 | 227 | break; |
| 228 | 228 | default: |
| 229 | 229 | throw new TDbException('dbconnection_unsupported_driver_charset', $driver); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * @return string the charset used for database connection. Defaults to emtpy string. |
| 285 | 285 | */ |
| 286 | - public function getCharset () |
|
| 286 | + public function getCharset() |
|
| 287 | 287 | { |
| 288 | 288 | return $this->_charset; |
| 289 | 289 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | /** |
| 292 | 292 | * @param string the charset used for database connection |
| 293 | 293 | */ |
| 294 | - public function setCharset ($value) |
|
| 294 | + public function setCharset($value) |
|
| 295 | 295 | { |
| 296 | 296 | $this->_charset=$value; |
| 297 | 297 | $this->setConnectionCharset(); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | public function createCommand($sql) |
| 315 | 315 | { |
| 316 | 316 | if($this->getActive()) |
| 317 | - return new TDbCommand($this,$sql); |
|
| 317 | + return new TDbCommand($this, $sql); |
|
| 318 | 318 | else |
| 319 | 319 | throw new TDbException('dbconnection_connection_inactive'); |
| 320 | 320 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | public function setTransactionClass($value) |
| 366 | 366 | { |
| 367 | - $this->_transactionClass = (string)$value; |
|
| 367 | + $this->_transactionClass=(string) $value; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if($this->_dbMeta===null) |
| 434 | 434 | { |
| 435 | 435 | Prado::using('System.Data.Common.TDbMetaData'); |
| 436 | - $this->_dbMeta = TDbMetaData::getInstance($this); |
|
| 436 | + $this->_dbMeta=TDbMetaData::getInstance($this); |
|
| 437 | 437 | } |
| 438 | 438 | return $this->_dbMeta; |
| 439 | 439 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function setColumnCase($value) |
| 461 | 461 | { |
| 462 | - switch(TPropertyValue::ensureEnum($value,'TDbColumnCaseMode')) |
|
| 462 | + switch(TPropertyValue::ensureEnum($value, 'TDbColumnCaseMode')) |
|
| 463 | 463 | { |
| 464 | 464 | case TDbColumnCaseMode::Preserved: |
| 465 | 465 | $value=PDO::CASE_NATURAL; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $value=PDO::CASE_UPPER; |
| 472 | 472 | break; |
| 473 | 473 | } |
| 474 | - $this->setAttribute(PDO::ATTR_CASE,$value); |
|
| 474 | + $this->setAttribute(PDO::ATTR_CASE, $value); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function setNullConversion($value) |
| 497 | 497 | { |
| 498 | - switch(TPropertyValue::ensureEnum($value,'TDbNullConversionMode')) |
|
| 498 | + switch(TPropertyValue::ensureEnum($value, 'TDbNullConversionMode')) |
|
| 499 | 499 | { |
| 500 | 500 | case TDbNullConversionMode::Preserved: |
| 501 | 501 | $value=PDO::NULL_NATURAL; |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | $value=PDO::NULL_TO_STRING; |
| 508 | 508 | break; |
| 509 | 509 | } |
| 510 | - $this->setAttribute(PDO::ATTR_ORACLE_NULLS,$value); |
|
| 510 | + $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | public function setAutoCommit($value) |
| 527 | 527 | { |
| 528 | - $this->setAttribute(PDO::ATTR_AUTOCOMMIT,TPropertyValue::ensureBoolean($value)); |
|
| 528 | + $this->setAttribute(PDO::ATTR_AUTOCOMMIT, TPropertyValue::ensureBoolean($value)); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function setPersistent($value) |
| 545 | 545 | { |
| 546 | - return $this->setAttribute(PDO::ATTR_PERSISTENT,TPropertyValue::ensureBoolean($value)); |
|
| 546 | + return $this->setAttribute(PDO::ATTR_PERSISTENT, TPropertyValue::ensureBoolean($value)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -623,10 +623,10 @@ discard block |
||
| 623 | 623 | * @param mixed the attribute value |
| 624 | 624 | * @see http://www.php.net/manual/en/function.PDO-setAttribute.php |
| 625 | 625 | */ |
| 626 | - public function setAttribute($name,$value) |
|
| 626 | + public function setAttribute($name, $value) |
|
| 627 | 627 | { |
| 628 | 628 | if($this->_pdo instanceof PDO) |
| 629 | - $this->_pdo->setAttribute($name,$value); |
|
| 629 | + $this->_pdo->setAttribute($name, $value); |
|
| 630 | 630 | else |
| 631 | 631 | $this->_attributes[$name]=$value; |
| 632 | 632 | } |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | public function bindColumn($column, &$value, $dataType=null) |
| 64 | 64 | { |
| 65 | 65 | if($dataType===null) |
| 66 | - $this->_statement->bindColumn($column,$value); |
|
| 66 | + $this->_statement->bindColumn($column, $value); |
|
| 67 | 67 | else |
| 68 | - $this->_statement->bindColumn($column,$value,$dataType); |
|
| 68 | + $this->_statement->bindColumn($column, $value, $dataType); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function setFetchMode($mode) |
| 75 | 75 | { |
| 76 | 76 | $params=func_get_args(); |
| 77 | - call_user_func_array(array($this->_statement,'setFetchMode'),$params); |
|
| 77 | + call_user_func_array(array($this->_statement, 'setFetchMode'), $params); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created |
| 103 | 103 | * @return mixed|false the populated object, false if no more row of data available |
| 104 | 104 | */ |
| 105 | - public function readObject($className,$fields) |
|
| 105 | + public function readObject($className, $fields) |
|
| 106 | 106 | { |
| 107 | - return $this->_statement->fetchObject($className,$fields); |
|
| 107 | + return $this->_statement->fetchObject($className, $fields); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function rewind() |
| 173 | 173 | { |
| 174 | - if($this->_index<0) |
|
| 174 | + if($this->_index < 0) |
|
| 175 | 175 | { |
| 176 | 176 | $this->_row=$this->_statement->fetch(); |
| 177 | 177 | $this->_index=0; |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | $object = $object[$prop]; |
| 62 | 62 | else |
| 63 | 63 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
| 64 | - } |
|
| 65 | - else if(is_object($object)) |
|
| 64 | + } else if(is_object($object)) |
|
| 66 | 65 | { |
| 67 | 66 | $getter = 'get'.$prop; |
| 68 | 67 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | $object = $object->{$prop}; |
| 74 | 73 | else |
| 75 | 74 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
| 76 | - } |
|
| 77 | - else |
|
| 75 | + } else |
|
| 78 | 76 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
| 79 | 77 | } |
| 80 | 78 | return $object; |
@@ -98,8 +96,7 @@ discard block |
||
| 98 | 96 | $object = $object[$prop]; |
| 99 | 97 | else |
| 100 | 98 | return false; |
| 101 | - } |
|
| 102 | - else if(is_object($object)) |
|
| 99 | + } else if(is_object($object)) |
|
| 103 | 100 | { |
| 104 | 101 | $getter = 'get'.$prop; |
| 105 | 102 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -110,8 +107,7 @@ discard block |
||
| 110 | 107 | $object = $object->{$prop}; |
| 111 | 108 | else |
| 112 | 109 | return false; |
| 113 | - } |
|
| 114 | - else |
|
| 110 | + } else |
|
| 115 | 111 | return false; |
| 116 | 112 | } |
| 117 | 113 | return true; |
@@ -136,16 +132,14 @@ discard block |
||
| 136 | 132 | if(is_array($object) || $object instanceof ArrayAccess) |
| 137 | 133 | { |
| 138 | 134 | $object[$prop] = $value; |
| 139 | - } |
|
| 140 | - else if(is_object($object)) |
|
| 135 | + } else if(is_object($object)) |
|
| 141 | 136 | { |
| 142 | 137 | $setter = 'set'.$prop; |
| 143 | 138 | if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
| 144 | 139 | $object->{$setter}($value); |
| 145 | 140 | else |
| 146 | 141 | $object->{$prop} = $value; |
| 147 | - } |
|
| 148 | - else |
|
| 142 | + } else |
|
| 149 | 143 | throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
| 150 | 144 | } |
| 151 | 145 | |
@@ -48,34 +48,34 @@ discard block |
||
| 48 | 48 | * @return mixed property value. |
| 49 | 49 | * @throws TInvalidDataValueException if property path is invalid. |
| 50 | 50 | */ |
| 51 | - public static function get($object,$path) |
|
| 51 | + public static function get($object, $path) |
|
| 52 | 52 | { |
| 53 | 53 | if(!is_array($object) && !is_object($object)) |
| 54 | 54 | return $object; |
| 55 | - $properties = explode('.', $path); |
|
| 55 | + $properties=explode('.', $path); |
|
| 56 | 56 | foreach($properties as $prop) |
| 57 | 57 | { |
| 58 | 58 | if(is_array($object) || $object instanceof ArrayAccess) |
| 59 | 59 | { |
| 60 | 60 | if(array_key_exists($prop, $object)) |
| 61 | - $object = $object[$prop]; |
|
| 61 | + $object=$object[$prop]; |
|
| 62 | 62 | else |
| 63 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
| 63 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
| 64 | 64 | } |
| 65 | 65 | else if(is_object($object)) |
| 66 | 66 | { |
| 67 | - $getter = 'get'.$prop; |
|
| 67 | + $getter='get'.$prop; |
|
| 68 | 68 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
| 69 | - $object = $object->{$getter}(); |
|
| 69 | + $object=$object->{$getter}(); |
|
| 70 | 70 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
| 71 | - $object = $object->{$prop}; |
|
| 71 | + $object=$object->{$prop}; |
|
| 72 | 72 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
| 73 | - $object = $object->{$prop}; |
|
| 73 | + $object=$object->{$prop}; |
|
| 74 | 74 | else |
| 75 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
| 75 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
| 76 | 76 | } |
| 77 | 77 | else |
| 78 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
| 78 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
| 79 | 79 | } |
| 80 | 80 | return $object; |
| 81 | 81 | } |
@@ -89,25 +89,25 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | if(!is_array($object) && !is_object($object)) |
| 91 | 91 | return false; |
| 92 | - $properties = explode('.', $path); |
|
| 92 | + $properties=explode('.', $path); |
|
| 93 | 93 | foreach($properties as $prop) |
| 94 | 94 | { |
| 95 | 95 | if(is_array($object) || $object instanceof ArrayAccess) |
| 96 | 96 | { |
| 97 | 97 | if(array_key_exists($prop, $object)) |
| 98 | - $object = $object[$prop]; |
|
| 98 | + $object=$object[$prop]; |
|
| 99 | 99 | else |
| 100 | 100 | return false; |
| 101 | 101 | } |
| 102 | 102 | else if(is_object($object)) |
| 103 | 103 | { |
| 104 | - $getter = 'get'.$prop; |
|
| 104 | + $getter='get'.$prop; |
|
| 105 | 105 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
| 106 | - $object = $object->{$getter}(); |
|
| 106 | + $object=$object->{$getter}(); |
|
| 107 | 107 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
| 108 | - $object = $object->{$prop}; |
|
| 108 | + $object=$object->{$prop}; |
|
| 109 | 109 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
| 110 | - $object = $object->{$prop}; |
|
| 110 | + $object=$object->{$prop}; |
|
| 111 | 111 | else |
| 112 | 112 | return false; |
| 113 | 113 | } |
@@ -126,27 +126,27 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public static function set(&$originalObject, $path, $value) |
| 128 | 128 | { |
| 129 | - $properties = explode('.', $path); |
|
| 130 | - $prop = array_pop($properties); |
|
| 129 | + $properties=explode('.', $path); |
|
| 130 | + $prop=array_pop($properties); |
|
| 131 | 131 | if(count($properties) > 0) |
| 132 | - $object = self::get($originalObject, implode('.',$properties)); |
|
| 132 | + $object=self::get($originalObject, implode('.', $properties)); |
|
| 133 | 133 | else |
| 134 | - $object = &$originalObject; |
|
| 134 | + $object=&$originalObject; |
|
| 135 | 135 | |
| 136 | 136 | if(is_array($object) || $object instanceof ArrayAccess) |
| 137 | 137 | { |
| 138 | - $object[$prop] = $value; |
|
| 138 | + $object[$prop]=$value; |
|
| 139 | 139 | } |
| 140 | 140 | else if(is_object($object)) |
| 141 | 141 | { |
| 142 | - $setter = 'set'.$prop; |
|
| 143 | - if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
| 142 | + $setter='set'.$prop; |
|
| 143 | + if(method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
| 144 | 144 | $object->{$setter}($value); |
| 145 | 145 | else |
| 146 | - $object->{$prop} = $value; |
|
| 146 | + $object->{$prop}=$value; |
|
| 147 | 147 | } |
| 148 | 148 | else |
| 149 | - throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
|
| 149 | + throw new TInvalidPropertyException('sqlmap_invalid_property_type', $path); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | } |