@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $this->loadParameters($config); |
| 62 | 62 | if($this->_paramFile!==null) |
| 63 | 63 | { |
| 64 | - $configFile = null; |
|
| 64 | + $configFile=null; |
|
| 65 | 65 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_XML && ($cache=$this->getApplication()->getCache())!==null) |
| 66 | 66 | { |
| 67 | 67 | $cacheKey='TParameterModule:'.$this->_paramFile; |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $configFile=new TXmlDocument; |
| 71 | 71 | $configFile->loadFromFile($this->_paramFile); |
| 72 | - $cache->set($cacheKey,$configFile,0,new TFileCacheDependency($this->_paramFile)); |
|
| 72 | + $cache->set($cacheKey, $configFile, 0, new TFileCacheDependency($this->_paramFile)); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | else |
| 76 | 76 | { |
| 77 | 77 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 78 | 78 | { |
| 79 | - $configFile = include $this->_paramFile; |
|
| 79 | + $configFile=include $this->_paramFile; |
|
| 80 | 80 | } |
| 81 | 81 | else |
| 82 | 82 | { |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | if(is_array($parameter) && isset($parameter['class'])) |
| 105 | 105 | { |
| 106 | - $properties = isset($parameter['properties'])?$parameter['properties']:array(); |
|
| 107 | - $parameters[$id]=array($parameter['class'],$properties); |
|
| 106 | + $properties=isset($parameter['properties']) ? $parameter['properties'] : array(); |
|
| 107 | + $parameters[$id]=array($parameter['class'], $properties); |
|
| 108 | 108 | } |
| 109 | 109 | else |
| 110 | 110 | { |
| 111 | - $parameters[$id] = $parameter; |
|
| 111 | + $parameters[$id]=$parameter; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $parameters[$id]=$value; |
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | - $parameters[$id]=array($type,$properties->toArray()); |
|
| 130 | + $parameters[$id]=array($type, $properties->toArray()); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $component=Prado::createComponent($parameter[0]); |
| 140 | 140 | foreach($parameter[1] as $name=>$value) |
| 141 | - $component->setSubProperty($name,$value); |
|
| 142 | - $appParams->add($id,$component); |
|
| 141 | + $component->setSubProperty($name, $value); |
|
| 142 | + $appParams->add($id, $component); |
|
| 143 | 143 | } |
| 144 | 144 | else |
| 145 | - $appParams->add($id,$parameter); |
|
| 145 | + $appParams->add($id, $parameter); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | if($this->_initialized) |
| 166 | 166 | throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
| 167 | - else if(($this->_paramFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
| 168 | - throw new TConfigurationException('parametermodule_parameterfile_invalid',$value); |
|
| 167 | + else if(($this->_paramFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
| 168 | + throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | * @param integer maximum depth that the dumper should go into the variable. Defaults to 10. |
| 41 | 41 | * @return string the string representation of the variable |
| 42 | 42 | */ |
| 43 | - public static function dump($var,$depth=10,$highlight=false) |
|
| 43 | + public static function dump($var, $depth=10, $highlight=false) |
|
| 44 | 44 | { |
| 45 | 45 | self::$_output=''; |
| 46 | 46 | self::$_objects=array(); |
| 47 | 47 | self::$_depth=$depth; |
| 48 | - self::dumpInternal($var,0); |
|
| 48 | + self::dumpInternal($var, 0); |
|
| 49 | 49 | if($highlight) |
| 50 | 50 | { |
| 51 | - $result=highlight_string("<?php\n".self::$_output,true); |
|
| 52 | - return preg_replace('/<\\?php<br \\/>/','',$result,1); |
|
| 51 | + $result=highlight_string("<?php\n".self::$_output, true); |
|
| 52 | + return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
|
| 53 | 53 | } |
| 54 | 54 | else |
| 55 | 55 | return self::$_output; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private static function dumpInternal($var,$level) |
|
| 58 | + private static function dumpInternal($var, $level) |
|
| 59 | 59 | { |
| 60 | 60 | switch(gettype($var)) |
| 61 | 61 | { |
| 62 | 62 | case 'boolean': |
| 63 | - self::$_output.=$var?'true':'false'; |
|
| 63 | + self::$_output.=$var ? 'true' : 'false'; |
|
| 64 | 64 | break; |
| 65 | 65 | case 'integer': |
| 66 | 66 | self::$_output.="$var"; |
@@ -81,41 +81,41 @@ discard block |
||
| 81 | 81 | self::$_output.='{unknown}'; |
| 82 | 82 | break; |
| 83 | 83 | case 'array': |
| 84 | - if(self::$_depth<=$level) |
|
| 84 | + if(self::$_depth <= $level) |
|
| 85 | 85 | self::$_output.='array(...)'; |
| 86 | 86 | else if(empty($var)) |
| 87 | 87 | self::$_output.='array()'; |
| 88 | 88 | else |
| 89 | 89 | { |
| 90 | 90 | $keys=array_keys($var); |
| 91 | - $spaces=str_repeat(' ',$level*4); |
|
| 91 | + $spaces=str_repeat(' ', $level * 4); |
|
| 92 | 92 | self::$_output.="array\n".$spaces.'('; |
| 93 | 93 | foreach($keys as $key) |
| 94 | 94 | { |
| 95 | 95 | self::$_output.="\n".$spaces." [$key] => "; |
| 96 | - self::$_output.=self::dumpInternal($var[$key],$level+1); |
|
| 96 | + self::$_output.=self::dumpInternal($var[$key], $level + 1); |
|
| 97 | 97 | } |
| 98 | 98 | self::$_output.="\n".$spaces.')'; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | case 'object': |
| 102 | - if(($id=array_search($var,self::$_objects,true))!==false) |
|
| 103 | - self::$_output.=get_class($var).'#'.($id+1).'(...)'; |
|
| 104 | - else if(self::$_depth<=$level) |
|
| 102 | + if(($id=array_search($var, self::$_objects, true))!==false) |
|
| 103 | + self::$_output.=get_class($var).'#'.($id + 1).'(...)'; |
|
| 104 | + else if(self::$_depth <= $level) |
|
| 105 | 105 | self::$_output.=get_class($var).'(...)'; |
| 106 | 106 | else |
| 107 | 107 | { |
| 108 | - $id=array_push(self::$_objects,$var); |
|
| 108 | + $id=array_push(self::$_objects, $var); |
|
| 109 | 109 | $className=get_class($var); |
| 110 | - $members=(array)$var; |
|
| 110 | + $members=(array) $var; |
|
| 111 | 111 | $keys=array_keys($members); |
| 112 | - $spaces=str_repeat(' ',$level*4); |
|
| 112 | + $spaces=str_repeat(' ', $level * 4); |
|
| 113 | 113 | self::$_output.="$className#$id\n".$spaces.'('; |
| 114 | 114 | foreach($keys as $key) |
| 115 | 115 | { |
| 116 | - $keyDisplay=strtr(trim($key),array("\0"=>':')); |
|
| 116 | + $keyDisplay=strtr(trim($key), array("\0"=>':')); |
|
| 117 | 117 | self::$_output.="\n".$spaces." [$keyDisplay] => "; |
| 118 | - self::$_output.=self::dumpInternal($members[$key],$level+1); |
|
| 118 | + self::$_output.=self::dumpInternal($members[$key], $level + 1); |
|
| 119 | 119 | } |
| 120 | 120 | self::$_output.="\n".$spaces.')'; |
| 121 | 121 | } |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function __construct($p_tarname) |
| 62 | 62 | { |
| 63 | - $this->_tarname = $p_tarname; |
|
| 63 | + $this->_tarname=$p_tarname; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function __destruct() |
| 67 | 67 | { |
| 68 | 68 | $this->_close(); |
| 69 | 69 | // ----- Look for a local copy to delete |
| 70 | - if ($this->_temp_tarname != '') |
|
| 70 | + if($this->_temp_tarname!='') |
|
| 71 | 71 | @unlink($this->_temp_tarname); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | protected function extractModify($p_path, $p_remove_path) |
| 112 | 112 | { |
| 113 | - $v_result = true; |
|
| 114 | - $v_list_detail = array(); |
|
| 113 | + $v_result=true; |
|
| 114 | + $v_list_detail=array(); |
|
| 115 | 115 | |
| 116 | - if ($v_result = $this->_openRead()) { |
|
| 117 | - $v_result = $this->_extractList($p_path, $v_list_detail, |
|
| 116 | + if($v_result=$this->_openRead()) { |
|
| 117 | + $v_result=$this->_extractList($p_path, $v_list_detail, |
|
| 118 | 118 | "complete", 0, $p_remove_path); |
| 119 | 119 | $this->_close(); |
| 120 | 120 | } |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | private function _isArchive($p_filename=null) |
| 131 | 131 | { |
| 132 | - if ($p_filename == null) { |
|
| 133 | - $p_filename = $this->_tarname; |
|
| 132 | + if($p_filename==null) { |
|
| 133 | + $p_filename=$this->_tarname; |
|
| 134 | 134 | } |
| 135 | 135 | clearstatcache(); |
| 136 | 136 | return @is_file($p_filename); |
@@ -138,39 +138,39 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | private function _openRead() |
| 140 | 140 | { |
| 141 | - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
| 141 | + if(strtolower(substr($this->_tarname, 0, 7))=='http://') { |
|
| 142 | 142 | |
| 143 | 143 | // ----- Look if a local copy need to be done |
| 144 | - if ($this->_temp_tarname == '') { |
|
| 145 | - $this->_temp_tarname = uniqid('tar').'.tmp'; |
|
| 146 | - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
| 144 | + if($this->_temp_tarname=='') { |
|
| 145 | + $this->_temp_tarname=uniqid('tar').'.tmp'; |
|
| 146 | + if(!$v_file_from=@fopen($this->_tarname, 'rb')) { |
|
| 147 | 147 | $this->_error('Unable to open in read mode \'' |
| 148 | 148 | .$this->_tarname.'\''); |
| 149 | - $this->_temp_tarname = ''; |
|
| 149 | + $this->_temp_tarname=''; |
|
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
| 152 | + if(!$v_file_to=@fopen($this->_temp_tarname, 'wb')) { |
|
| 153 | 153 | $this->_error('Unable to open in write mode \'' |
| 154 | 154 | .$this->_temp_tarname.'\''); |
| 155 | - $this->_temp_tarname = ''; |
|
| 155 | + $this->_temp_tarname=''; |
|
| 156 | 156 | return false; |
| 157 | 157 | } |
| 158 | - while ($v_data = @fread($v_file_from, 1024)) |
|
| 158 | + while($v_data=@fread($v_file_from, 1024)) |
|
| 159 | 159 | @fwrite($v_file_to, $v_data); |
| 160 | 160 | @fclose($v_file_from); |
| 161 | 161 | @fclose($v_file_to); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // ----- File to open if the local copy |
| 165 | - $v_filename = $this->_temp_tarname; |
|
| 165 | + $v_filename=$this->_temp_tarname; |
|
| 166 | 166 | |
| 167 | 167 | } else |
| 168 | 168 | // ----- File to open if the normal Tar file |
| 169 | - $v_filename = $this->_tarname; |
|
| 169 | + $v_filename=$this->_tarname; |
|
| 170 | 170 | |
| 171 | - $this->_file = @fopen($v_filename, "rb"); |
|
| 171 | + $this->_file=@fopen($v_filename, "rb"); |
|
| 172 | 172 | |
| 173 | - if ($this->_file == 0) { |
|
| 173 | + if($this->_file==0) { |
|
| 174 | 174 | $this->_error('Unable to open in read mode \''.$v_filename.'\''); |
| 175 | 175 | return false; |
| 176 | 176 | } |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | private function _close() |
| 182 | 182 | { |
| 183 | 183 | //if (isset($this->_file)) { |
| 184 | - if (is_resource($this->_file)) |
|
| 184 | + if(is_resource($this->_file)) |
|
| 185 | 185 | { |
| 186 | 186 | @fclose($this->_file); |
| 187 | - $this->_file = 0; |
|
| 187 | + $this->_file=0; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // ----- Look if a local copy need to be erase |
| 191 | 191 | // Note that it might be interesting to keep the url for a time : ToDo |
| 192 | - if ($this->_temp_tarname != '') { |
|
| 192 | + if($this->_temp_tarname!='') { |
|
| 193 | 193 | @unlink($this->_temp_tarname); |
| 194 | - $this->_temp_tarname = ''; |
|
| 194 | + $this->_temp_tarname=''; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return true; |
@@ -202,76 +202,76 @@ discard block |
||
| 202 | 202 | $this->_close(); |
| 203 | 203 | |
| 204 | 204 | // ----- Look for a local copy |
| 205 | - if ($this->_temp_tarname != '') { |
|
| 205 | + if($this->_temp_tarname!='') { |
|
| 206 | 206 | // ----- Remove the local copy but not the remote tarname |
| 207 | 207 | @unlink($this->_temp_tarname); |
| 208 | - $this->_temp_tarname = ''; |
|
| 208 | + $this->_temp_tarname=''; |
|
| 209 | 209 | } else { |
| 210 | 210 | // ----- Remove the local tarname file |
| 211 | 211 | @unlink($this->_tarname); |
| 212 | 212 | } |
| 213 | - $this->_tarname = ''; |
|
| 213 | + $this->_tarname=''; |
|
| 214 | 214 | |
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | private function _readBlock() |
| 219 | 219 | { |
| 220 | - $v_block = null; |
|
| 221 | - if (is_resource($this->_file)) { |
|
| 222 | - $v_block = @fread($this->_file, 512); |
|
| 220 | + $v_block=null; |
|
| 221 | + if(is_resource($this->_file)) { |
|
| 222 | + $v_block=@fread($this->_file, 512); |
|
| 223 | 223 | } |
| 224 | 224 | return $v_block; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | private function _jumpBlock($p_len=null) |
| 228 | 228 | { |
| 229 | - if (is_resource($this->_file)) { |
|
| 230 | - if ($p_len === null) |
|
| 231 | - $p_len = 1; |
|
| 229 | + if(is_resource($this->_file)) { |
|
| 230 | + if($p_len===null) |
|
| 231 | + $p_len=1; |
|
| 232 | 232 | |
| 233 | - @fseek($this->_file, @ftell($this->_file)+($p_len*512)); |
|
| 233 | + @fseek($this->_file, @ftell($this->_file) + ($p_len * 512)); |
|
| 234 | 234 | } |
| 235 | 235 | return true; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | private function _readHeader($v_binary_data, &$v_header) |
| 239 | 239 | { |
| 240 | - if (strlen($v_binary_data)==0) { |
|
| 241 | - $v_header['filename'] = ''; |
|
| 240 | + if(strlen($v_binary_data)==0) { |
|
| 241 | + $v_header['filename']=''; |
|
| 242 | 242 | return true; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if (strlen($v_binary_data) != 512) { |
|
| 246 | - $v_header['filename'] = ''; |
|
| 245 | + if(strlen($v_binary_data)!=512) { |
|
| 246 | + $v_header['filename']=''; |
|
| 247 | 247 | $this->_error('Invalid block size : '.strlen($v_binary_data)); |
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // ----- Calculate the checksum |
| 252 | - $v_checksum = 0; |
|
| 252 | + $v_checksum=0; |
|
| 253 | 253 | // ..... First part of the header |
| 254 | - for ($i=0; $i<148; $i++) |
|
| 255 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 254 | + for($i=0; $i < 148; $i++) |
|
| 255 | + $v_checksum+=ord(substr($v_binary_data, $i, 1)); |
|
| 256 | 256 | // ..... Ignore the checksum value and replace it by ' ' (space) |
| 257 | - for ($i=148; $i<156; $i++) |
|
| 258 | - $v_checksum += ord(' '); |
|
| 257 | + for($i=148; $i < 156; $i++) |
|
| 258 | + $v_checksum+=ord(' '); |
|
| 259 | 259 | // ..... Last part of the header |
| 260 | - for ($i=156; $i<512; $i++) |
|
| 261 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 260 | + for($i=156; $i < 512; $i++) |
|
| 261 | + $v_checksum+=ord(substr($v_binary_data, $i, 1)); |
|
| 262 | 262 | |
| 263 | - $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
| 263 | + $v_data=unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
| 264 | 264 | ."a8checksum/a1typeflag/a100link/a6magic/a2version/" |
| 265 | 265 | ."a32uname/a32gname/a8devmajor/a8devminor", |
| 266 | 266 | $v_binary_data); |
| 267 | 267 | |
| 268 | 268 | // ----- Extract the checksum |
| 269 | - $v_header['checksum'] = OctDec(trim($v_data['checksum'])); |
|
| 270 | - if ($v_header['checksum'] != $v_checksum) { |
|
| 271 | - $v_header['filename'] = ''; |
|
| 269 | + $v_header['checksum']=OctDec(trim($v_data['checksum'])); |
|
| 270 | + if($v_header['checksum']!=$v_checksum) { |
|
| 271 | + $v_header['filename']=''; |
|
| 272 | 272 | |
| 273 | 273 | // ----- Look for last block (empty block) |
| 274 | - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
| 274 | + if(($v_checksum==256) && ($v_header['checksum']==0)) |
|
| 275 | 275 | return true; |
| 276 | 276 | |
| 277 | 277 | $this->_error('Invalid checksum for file "'.$v_data['filename'] |
@@ -281,38 +281,38 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // ----- Extract the properties |
| 284 | - $v_header['filename'] = trim($v_data['filename']); |
|
| 285 | - $v_header['mode'] = OctDec(trim($v_data['mode'])); |
|
| 286 | - $v_header['uid'] = OctDec(trim($v_data['uid'])); |
|
| 287 | - $v_header['gid'] = OctDec(trim($v_data['gid'])); |
|
| 288 | - $v_header['size'] = OctDec(trim($v_data['size'])); |
|
| 289 | - $v_header['mtime'] = OctDec(trim($v_data['mtime'])); |
|
| 290 | - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
| 291 | - $v_header['size'] = 0; |
|
| 284 | + $v_header['filename']=trim($v_data['filename']); |
|
| 285 | + $v_header['mode']=OctDec(trim($v_data['mode'])); |
|
| 286 | + $v_header['uid']=OctDec(trim($v_data['uid'])); |
|
| 287 | + $v_header['gid']=OctDec(trim($v_data['gid'])); |
|
| 288 | + $v_header['size']=OctDec(trim($v_data['size'])); |
|
| 289 | + $v_header['mtime']=OctDec(trim($v_data['mtime'])); |
|
| 290 | + if(($v_header['typeflag']=$v_data['typeflag'])=="5") { |
|
| 291 | + $v_header['size']=0; |
|
| 292 | 292 | } |
| 293 | 293 | return true; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | private function _readLongHeader(&$v_header) |
| 297 | 297 | { |
| 298 | - $v_filename = ''; |
|
| 299 | - $n = floor($v_header['size']/512); |
|
| 300 | - for ($i=0; $i<$n; $i++) { |
|
| 301 | - $v_content = $this->_readBlock(); |
|
| 302 | - $v_filename .= $v_content; |
|
| 298 | + $v_filename=''; |
|
| 299 | + $n=floor($v_header['size'] / 512); |
|
| 300 | + for($i=0; $i < $n; $i++) { |
|
| 301 | + $v_content=$this->_readBlock(); |
|
| 302 | + $v_filename.=$v_content; |
|
| 303 | 303 | } |
| 304 | - if (($v_header['size'] % 512) != 0) { |
|
| 305 | - $v_content = $this->_readBlock(); |
|
| 306 | - $v_filename .= $v_content; |
|
| 304 | + if(($v_header['size'] % 512)!=0) { |
|
| 305 | + $v_content=$this->_readBlock(); |
|
| 306 | + $v_filename.=$v_content; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // ----- Read the next header |
| 310 | - $v_binary_data = $this->_readBlock(); |
|
| 310 | + $v_binary_data=$this->_readBlock(); |
|
| 311 | 311 | |
| 312 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 312 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
| 313 | 313 | return false; |
| 314 | 314 | |
| 315 | - $v_header['filename'] = $v_filename; |
|
| 315 | + $v_header['filename']=$v_filename; |
|
| 316 | 316 | |
| 317 | 317 | return true; |
| 318 | 318 | } |
@@ -321,34 +321,34 @@ discard block |
||
| 321 | 321 | $p_file_list, $p_remove_path) |
| 322 | 322 | { |
| 323 | 323 | $v_result=true; |
| 324 | - $v_nb = 0; |
|
| 325 | - $v_extract_all = true; |
|
| 326 | - $v_listing = false; |
|
| 327 | - |
|
| 328 | - $p_path = $this->_translateWinPath($p_path, false); |
|
| 329 | - if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
| 330 | - && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
|
| 331 | - $p_path = "./".$p_path; |
|
| 324 | + $v_nb=0; |
|
| 325 | + $v_extract_all=true; |
|
| 326 | + $v_listing=false; |
|
| 327 | + |
|
| 328 | + $p_path=$this->_translateWinPath($p_path, false); |
|
| 329 | + if($p_path=='' || (substr($p_path, 0, 1)!='/' |
|
| 330 | + && substr($p_path, 0, 3)!="../" && !strpos($p_path, ':'))) { |
|
| 331 | + $p_path="./".$p_path; |
|
| 332 | 332 | } |
| 333 | - $p_remove_path = $this->_translateWinPath($p_remove_path); |
|
| 333 | + $p_remove_path=$this->_translateWinPath($p_remove_path); |
|
| 334 | 334 | |
| 335 | 335 | // ----- Look for path to remove format (should end by /) |
| 336 | - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
| 337 | - $p_remove_path .= '/'; |
|
| 338 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 336 | + if(($p_remove_path!='') && (substr($p_remove_path, -1)!='/')) |
|
| 337 | + $p_remove_path.='/'; |
|
| 338 | + $p_remove_path_size=strlen($p_remove_path); |
|
| 339 | 339 | |
| 340 | - switch ($p_mode) { |
|
| 340 | + switch($p_mode) { |
|
| 341 | 341 | case "complete" : |
| 342 | - $v_extract_all = true; |
|
| 343 | - $v_listing = false; |
|
| 342 | + $v_extract_all=true; |
|
| 343 | + $v_listing=false; |
|
| 344 | 344 | break; |
| 345 | 345 | case "partial" : |
| 346 | - $v_extract_all = false; |
|
| 347 | - $v_listing = false; |
|
| 346 | + $v_extract_all=false; |
|
| 347 | + $v_listing=false; |
|
| 348 | 348 | break; |
| 349 | 349 | case "list" : |
| 350 | - $v_extract_all = false; |
|
| 351 | - $v_listing = true; |
|
| 350 | + $v_extract_all=false; |
|
| 351 | + $v_listing=true; |
|
| 352 | 352 | break; |
| 353 | 353 | default : |
| 354 | 354 | $this->_error('Invalid extract mode ('.$p_mode.')'); |
@@ -357,103 +357,103 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | clearstatcache(); |
| 359 | 359 | |
| 360 | - while (strlen($v_binary_data = $this->_readBlock()) != 0) |
|
| 360 | + while(strlen($v_binary_data=$this->_readBlock())!=0) |
|
| 361 | 361 | { |
| 362 | - $v_extract_file = false; |
|
| 363 | - $v_extraction_stopped = 0; |
|
| 362 | + $v_extract_file=false; |
|
| 363 | + $v_extraction_stopped=0; |
|
| 364 | 364 | |
| 365 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 365 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
| 366 | 366 | return false; |
| 367 | 367 | |
| 368 | - if ($v_header['filename'] == '') { |
|
| 368 | + if($v_header['filename']=='') { |
|
| 369 | 369 | continue; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // ----- Look for long filename |
| 373 | - if ($v_header['typeflag'] == 'L') { |
|
| 374 | - if (!$this->_readLongHeader($v_header)) |
|
| 373 | + if($v_header['typeflag']=='L') { |
|
| 374 | + if(!$this->_readLongHeader($v_header)) |
|
| 375 | 375 | return false; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ((!$v_extract_all) && (is_array($p_file_list))) { |
|
| 378 | + if((!$v_extract_all) && (is_array($p_file_list))) { |
|
| 379 | 379 | // ----- By default no unzip if the file is not found |
| 380 | - $v_extract_file = false; |
|
| 380 | + $v_extract_file=false; |
|
| 381 | 381 | |
| 382 | - for ($i=0; $i<sizeof($p_file_list); $i++) { |
|
| 382 | + for($i=0; $i < sizeof($p_file_list); $i++) { |
|
| 383 | 383 | // ----- Look if it is a directory |
| 384 | - if (substr($p_file_list[$i], -1) == '/') { |
|
| 384 | + if(substr($p_file_list[$i], -1)=='/') { |
|
| 385 | 385 | // ----- Look if the directory is in the filename path |
| 386 | - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
| 386 | + if((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
| 387 | 387 | && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
| 388 | 388 | == $p_file_list[$i])) { |
| 389 | - $v_extract_file = true; |
|
| 389 | + $v_extract_file=true; |
|
| 390 | 390 | break; |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // ----- It is a file, so compare the file names |
| 395 | - elseif ($p_file_list[$i] == $v_header['filename']) { |
|
| 396 | - $v_extract_file = true; |
|
| 395 | + elseif($p_file_list[$i]==$v_header['filename']) { |
|
| 396 | + $v_extract_file=true; |
|
| 397 | 397 | break; |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } else { |
| 401 | - $v_extract_file = true; |
|
| 401 | + $v_extract_file=true; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // ----- Look if this file need to be extracted |
| 405 | - if (($v_extract_file) && (!$v_listing)) |
|
| 405 | + if(($v_extract_file) && (!$v_listing)) |
|
| 406 | 406 | { |
| 407 | - if (($p_remove_path != '') |
|
| 407 | + if(($p_remove_path!='') |
|
| 408 | 408 | && (substr($v_header['filename'], 0, $p_remove_path_size) |
| 409 | 409 | == $p_remove_path)) |
| 410 | - $v_header['filename'] = substr($v_header['filename'], |
|
| 410 | + $v_header['filename']=substr($v_header['filename'], |
|
| 411 | 411 | $p_remove_path_size); |
| 412 | - if (($p_path != './') && ($p_path != '/')) { |
|
| 413 | - while (substr($p_path, -1) == '/') |
|
| 414 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 412 | + if(($p_path!='./') && ($p_path!='/')) { |
|
| 413 | + while(substr($p_path, -1)=='/') |
|
| 414 | + $p_path=substr($p_path, 0, strlen($p_path) - 1); |
|
| 415 | 415 | |
| 416 | - if (substr($v_header['filename'], 0, 1) == '/') |
|
| 417 | - $v_header['filename'] = $p_path.$v_header['filename']; |
|
| 416 | + if(substr($v_header['filename'], 0, 1)=='/') |
|
| 417 | + $v_header['filename']=$p_path.$v_header['filename']; |
|
| 418 | 418 | else |
| 419 | - $v_header['filename'] = $p_path.'/'.$v_header['filename']; |
|
| 419 | + $v_header['filename']=$p_path.'/'.$v_header['filename']; |
|
| 420 | 420 | } |
| 421 | - if (file_exists($v_header['filename'])) { |
|
| 422 | - if ( (@is_dir($v_header['filename'])) |
|
| 423 | - && ($v_header['typeflag'] == '')) { |
|
| 421 | + if(file_exists($v_header['filename'])) { |
|
| 422 | + if((@is_dir($v_header['filename'])) |
|
| 423 | + && ($v_header['typeflag']=='')) { |
|
| 424 | 424 | $this->_error('File '.$v_header['filename'] |
| 425 | 425 | .' already exists as a directory'); |
| 426 | 426 | return false; |
| 427 | 427 | } |
| 428 | - if ( ($this->_isArchive($v_header['filename'])) |
|
| 429 | - && ($v_header['typeflag'] == "5")) { |
|
| 428 | + if(($this->_isArchive($v_header['filename'])) |
|
| 429 | + && ($v_header['typeflag']=="5")) { |
|
| 430 | 430 | $this->_error('Directory '.$v_header['filename'] |
| 431 | 431 | .' already exists as a file'); |
| 432 | 432 | return false; |
| 433 | 433 | } |
| 434 | - if (!is_writeable($v_header['filename'])) { |
|
| 434 | + if(!is_writeable($v_header['filename'])) { |
|
| 435 | 435 | $this->_error('File '.$v_header['filename'] |
| 436 | 436 | .' already exists and is write protected'); |
| 437 | 437 | return false; |
| 438 | 438 | } |
| 439 | - if (filemtime($v_header['filename']) > $v_header['mtime']) { |
|
| 439 | + if(filemtime($v_header['filename']) > $v_header['mtime']) { |
|
| 440 | 440 | // To be completed : An error or silent no replace ? |
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // ----- Check the directory availability and create it if necessary |
| 445 | - elseif (($v_result |
|
| 446 | - = $this->_dirCheck(($v_header['typeflag'] == "5" |
|
| 447 | - ?$v_header['filename'] |
|
| 448 | - :dirname($v_header['filename'])))) != 1) { |
|
| 445 | + elseif(($v_result |
|
| 446 | + = $this->_dirCheck(($v_header['typeflag']=="5" |
|
| 447 | + ? $v_header['filename'] |
|
| 448 | + :dirname($v_header['filename']))))!=1) { |
|
| 449 | 449 | $this->_error('Unable to create path for '.$v_header['filename']); |
| 450 | 450 | return false; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ($v_extract_file) { |
|
| 454 | - if ($v_header['typeflag'] == "5") { |
|
| 455 | - if (!@file_exists($v_header['filename'])) { |
|
| 456 | - if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
| 453 | + if($v_extract_file) { |
|
| 454 | + if($v_header['typeflag']=="5") { |
|
| 455 | + if(!@file_exists($v_header['filename'])) { |
|
| 456 | + if(!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
| 457 | 457 | $this->_error('Unable to create directory {' |
| 458 | 458 | .$v_header['filename'].'}'); |
| 459 | 459 | return false; |
@@ -461,18 +461,18 @@ discard block |
||
| 461 | 461 | chmod($v_header['filename'], PRADO_CHMOD); |
| 462 | 462 | } |
| 463 | 463 | } else { |
| 464 | - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
| 464 | + if(($v_dest_file=@fopen($v_header['filename'], "wb"))==0) { |
|
| 465 | 465 | $this->_error('Error while opening {'.$v_header['filename'] |
| 466 | 466 | .'} in write binary mode'); |
| 467 | 467 | return false; |
| 468 | 468 | } else { |
| 469 | - $n = floor($v_header['size']/512); |
|
| 470 | - for ($i=0; $i<$n; $i++) { |
|
| 471 | - $v_content = $this->_readBlock(); |
|
| 469 | + $n=floor($v_header['size'] / 512); |
|
| 470 | + for($i=0; $i < $n; $i++) { |
|
| 471 | + $v_content=$this->_readBlock(); |
|
| 472 | 472 | fwrite($v_dest_file, $v_content, 512); |
| 473 | 473 | } |
| 474 | - if (($v_header['size'] % 512) != 0) { |
|
| 475 | - $v_content = $this->_readBlock(); |
|
| 474 | + if(($v_header['size'] % 512)!=0) { |
|
| 475 | + $v_content=$this->_readBlock(); |
|
| 476 | 476 | fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | // ----- Check the file size |
| 488 | 488 | clearstatcache(); |
| 489 | - if (filesize($v_header['filename']) != $v_header['size']) { |
|
| 489 | + if(filesize($v_header['filename'])!=$v_header['size']) { |
|
| 490 | 490 | $this->_error('Extracted file '.$v_header['filename'] |
| 491 | 491 | .' does not have the correct file size \'' |
| 492 | 492 | .filesize($v_header['filename']) |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | } else { |
| 499 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 499 | + $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
|
| 500 | 500 | } |
| 501 | 501 | } else { |
| 502 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 502 | + $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /* TBC : Seems to be unused ... |
@@ -509,15 +509,15 @@ discard block |
||
| 509 | 509 | $v_end_of_file = @feof($this->_file); |
| 510 | 510 | */ |
| 511 | 511 | |
| 512 | - if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
| 512 | + if($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
| 513 | 513 | // ----- Log extracted files |
| 514 | - if (($v_file_dir = dirname($v_header['filename'])) |
|
| 514 | + if(($v_file_dir=dirname($v_header['filename'])) |
|
| 515 | 515 | == $v_header['filename']) |
| 516 | - $v_file_dir = ''; |
|
| 517 | - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
| 518 | - $v_file_dir = '/'; |
|
| 516 | + $v_file_dir=''; |
|
| 517 | + if((substr($v_header['filename'], 0, 1)=='/') && ($v_file_dir=='')) |
|
| 518 | + $v_file_dir='/'; |
|
| 519 | 519 | |
| 520 | - $p_list_detail[$v_nb++] = $v_header; |
|
| 520 | + $p_list_detail[$v_nb++]=$v_header; |
|
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | 523 | |
@@ -534,36 +534,36 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | protected function _dirCheck($p_dir) |
| 536 | 536 | { |
| 537 | - if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
| 537 | + if((@is_dir($p_dir)) || ($p_dir=='')) |
|
| 538 | 538 | return true; |
| 539 | 539 | |
| 540 | - $p_parent_dir = dirname($p_dir); |
|
| 540 | + $p_parent_dir=dirname($p_dir); |
|
| 541 | 541 | |
| 542 | - if (($p_parent_dir != $p_dir) && |
|
| 543 | - ($p_parent_dir != '') && |
|
| 542 | + if(($p_parent_dir!=$p_dir) && |
|
| 543 | + ($p_parent_dir!='') && |
|
| 544 | 544 | (!$this->_dirCheck($p_parent_dir))) |
| 545 | 545 | return false; |
| 546 | 546 | |
| 547 | - if (!@mkdir($p_dir, PRADO_CHMOD)) { |
|
| 547 | + if(!@mkdir($p_dir, PRADO_CHMOD)) { |
|
| 548 | 548 | $this->_error("Unable to create directory '$p_dir'"); |
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | - chmod($p_dir,PRADO_CHMOD); |
|
| 551 | + chmod($p_dir, PRADO_CHMOD); |
|
| 552 | 552 | |
| 553 | 553 | return true; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | protected function _translateWinPath($p_path, $p_remove_disk_letter=true) |
| 557 | 557 | { |
| 558 | - if (substr(PHP_OS, 0, 3) == 'WIN') { |
|
| 558 | + if(substr(PHP_OS, 0, 3)=='WIN') { |
|
| 559 | 559 | // ----- Look for potential disk letter |
| 560 | - if ( ($p_remove_disk_letter) |
|
| 561 | - && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 562 | - $p_path = substr($p_path, $v_position+1); |
|
| 560 | + if(($p_remove_disk_letter) |
|
| 561 | + && (($v_position=strpos($p_path, ':'))!=false)) { |
|
| 562 | + $p_path=substr($p_path, $v_position + 1); |
|
| 563 | 563 | } |
| 564 | 564 | // ----- Change potential windows directory separator |
| 565 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 566 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 565 | + if((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1)=='\\')) { |
|
| 566 | + $p_path=strtr($p_path, '\\', '/'); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | return $p_path; |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * @return string SQL search condition matching on a set of columns. |
| 31 | 31 | */ |
| 32 | 32 | public function getSearchExpression($fields, $keywords) { |
| 33 | - $columns = array (); |
|
| 34 | - foreach ($fields as $field) { |
|
| 35 | - if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
| 36 | - $columns[] = $field; |
|
| 33 | + $columns=array(); |
|
| 34 | + foreach($fields as $field) { |
|
| 35 | + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
| 36 | + $columns[]=$field; |
|
| 37 | 37 | } |
| 38 | 38 | return parent :: getSearchExpression($columns, $keywords); |
| 39 | 39 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @return boolean true if column can be used for LIKE searching. |
| 43 | 43 | */ |
| 44 | 44 | protected function isSearchableColumn($column) { |
| 45 | - $type = strtolower($column->getDbType()); |
|
| 46 | - return $type === 'character varying' || $type === 'varchar2' || $type === 'character' || $type === 'char' || $type === 'text'; |
|
| 45 | + $type=strtolower($column->getDbType()); |
|
| 46 | + return $type==='character varying' || $type==='varchar2' || $type==='character' || $type==='char' || $type==='text'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -72,59 +72,59 @@ discard block |
||
| 72 | 72 | * @param integer row offset, -1 to ignore offset. |
| 73 | 73 | * @return string SQL with limit and offset in Oracle way. |
| 74 | 74 | */ |
| 75 | - public function applyLimitOffset($sql, $limit = -1, $offset = -1) { |
|
| 76 | - if ((int) $limit <= 0 && (int) $offset <= 0) |
|
| 75 | + public function applyLimitOffset($sql, $limit=-1, $offset=-1) { |
|
| 76 | + if((int) $limit <= 0 && (int) $offset <= 0) |
|
| 77 | 77 | return $sql; |
| 78 | 78 | |
| 79 | - $pradoNUMLIN = 'pradoNUMLIN'; |
|
| 80 | - $fieldsALIAS = 'xyz'; |
|
| 79 | + $pradoNUMLIN='pradoNUMLIN'; |
|
| 80 | + $fieldsALIAS='xyz'; |
|
| 81 | 81 | |
| 82 | - $nfimDaSQL = strlen($sql); |
|
| 83 | - $nfimDoWhere = (strpos($sql, 'ORDER') !== false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
| 84 | - $niniDoSelect = strpos($sql, 'SELECT') + 6; |
|
| 85 | - $nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
| 82 | + $nfimDaSQL=strlen($sql); |
|
| 83 | + $nfimDoWhere=(strpos($sql, 'ORDER')!==false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
| 84 | + $niniDoSelect=strpos($sql, 'SELECT') + 6; |
|
| 85 | + $nfimDoSelect=(strpos($sql, 'FROM')!==false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
| 86 | 86 | |
| 87 | 87 | $WhereInSubSelect=""; |
| 88 | 88 | if(strpos($sql, 'WHERE')!==false) |
| 89 | - $WhereInSubSelect = "WHERE " .substr($sql, strpos($sql, 'WHERE')+5, $nfimDoWhere - $niniDoWhere); |
|
| 89 | + $WhereInSubSelect="WHERE ".substr($sql, strpos($sql, 'WHERE') + 5, $nfimDoWhere - $niniDoWhere); |
|
| 90 | 90 | |
| 91 | - $sORDERBY = ''; |
|
| 92 | - if (stripos($sql, 'ORDER') !== false) { |
|
| 93 | - $p = stripos($sql, 'ORDER'); |
|
| 94 | - $sORDERBY = substr($sql, $p +8); |
|
| 91 | + $sORDERBY=''; |
|
| 92 | + if(stripos($sql, 'ORDER')!==false) { |
|
| 93 | + $p=stripos($sql, 'ORDER'); |
|
| 94 | + $sORDERBY=substr($sql, $p + 8); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $fields = substr($sql, 0, $nfimDoSelect); |
|
| 98 | - $fields = trim(substr($fields, $niniDoSelect)); |
|
| 99 | - $aliasedFields = ', '; |
|
| 97 | + $fields=substr($sql, 0, $nfimDoSelect); |
|
| 98 | + $fields=trim(substr($fields, $niniDoSelect)); |
|
| 99 | + $aliasedFields=', '; |
|
| 100 | 100 | |
| 101 | - if (trim($fields) == '*') { |
|
| 102 | - $aliasedFields = ", {$fieldsALIAS}.{$fields}"; |
|
| 103 | - $fields = ''; |
|
| 104 | - $arr = $this->getTableInfo()->getColumns(); |
|
| 105 | - foreach ($arr as $field) { |
|
| 106 | - $fields .= strtolower($field->getColumnName()) . ', '; |
|
| 101 | + if(trim($fields)=='*') { |
|
| 102 | + $aliasedFields=", {$fieldsALIAS}.{$fields}"; |
|
| 103 | + $fields=''; |
|
| 104 | + $arr=$this->getTableInfo()->getColumns(); |
|
| 105 | + foreach($arr as $field) { |
|
| 106 | + $fields.=strtolower($field->getColumnName()).', '; |
|
| 107 | 107 | } |
| 108 | - $fields = str_replace('"', '', $fields); |
|
| 109 | - $fields = trim($fields); |
|
| 110 | - $fields = substr($fields, 0, strlen($fields) - 1); |
|
| 108 | + $fields=str_replace('"', '', $fields); |
|
| 109 | + $fields=trim($fields); |
|
| 110 | + $fields=substr($fields, 0, strlen($fields) - 1); |
|
| 111 | 111 | } else { |
| 112 | - if (strpos($fields, ',') !== false) { |
|
| 113 | - $arr = $this->getTableInfo()->getColumns(); |
|
| 114 | - foreach ($arr as $field) { |
|
| 115 | - $field = strtolower($field); |
|
| 116 | - $existAS = str_ireplace(' as ', '-as-', $field); |
|
| 117 | - if (strpos($existAS, '-as-') === false) |
|
| 118 | - $aliasedFields .= "{$fieldsALIAS}." . trim($field) . ", "; |
|
| 112 | + if(strpos($fields, ',')!==false) { |
|
| 113 | + $arr=$this->getTableInfo()->getColumns(); |
|
| 114 | + foreach($arr as $field) { |
|
| 115 | + $field=strtolower($field); |
|
| 116 | + $existAS=str_ireplace(' as ', '-as-', $field); |
|
| 117 | + if(strpos($existAS, '-as-')===false) |
|
| 118 | + $aliasedFields.="{$fieldsALIAS}.".trim($field).", "; |
|
| 119 | 119 | else |
| 120 | - $aliasedFields .= "{$field}, "; |
|
| 120 | + $aliasedFields.="{$field}, "; |
|
| 121 | 121 | } |
| 122 | - $aliasedFields = trim($aliasedFields); |
|
| 123 | - $aliasedFields = substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
| 122 | + $aliasedFields=trim($aliasedFields); |
|
| 123 | + $aliasedFields=substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - if ($aliasedFields == ', ') |
|
| 127 | - $aliasedFields = " , $fieldsALIAS.* "; |
|
| 126 | + if($aliasedFields==', ') |
|
| 127 | + $aliasedFields=" , $fieldsALIAS.* "; |
|
| 128 | 128 | |
| 129 | 129 | /* ************************ |
| 130 | 130 | $newSql = " SELECT $fields FROM ". |
@@ -134,17 +134,17 @@ discard block |
||
| 134 | 134 | ") WHERE {$pradoNUMLIN} >= {$offset} "; |
| 135 | 135 | |
| 136 | 136 | ************************* */ |
| 137 | - $offset=(int)$offset; |
|
| 138 | - $toReg = $offset + $limit ; |
|
| 139 | - $fullTableName = $this->getTableInfo()->getTableFullName(); |
|
| 140 | - if (empty ($sORDERBY)) |
|
| 137 | + $offset=(int) $offset; |
|
| 138 | + $toReg=$offset + $limit; |
|
| 139 | + $fullTableName=$this->getTableInfo()->getTableFullName(); |
|
| 140 | + if(empty ($sORDERBY)) |
|
| 141 | 141 | $sORDERBY="ROWNUM"; |
| 142 | 142 | |
| 143 | - $newSql = " SELECT $fields FROM " . |
|
| 144 | - "( " . |
|
| 145 | - " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " . |
|
| 146 | - " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" . |
|
| 147 | - ") nn " . |
|
| 143 | + $newSql=" SELECT $fields FROM ". |
|
| 144 | + "( ". |
|
| 145 | + " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} ". |
|
| 146 | + " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect". |
|
| 147 | + ") nn ". |
|
| 148 | 148 | " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} < {$toReg} "; |
| 149 | 149 | //echo $newSql."\n<br>\n"; |
| 150 | 150 | return $newSql; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | class TOracleTableColumn extends TDbTableColumn |
| 25 | 25 | { |
| 26 | 26 | private static $types=array( |
| 27 | - 'numeric' => array( 'numeric' ) |
|
| 27 | + 'numeric' => array('numeric') |
|
| 28 | 28 | // 'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'), |
| 29 | 29 | // 'boolean' => array('boolean'), |
| 30 | 30 | // 'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric') |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function getPHPType() |
| 38 | 38 | { |
| 39 | - $dbtype = strtolower($this->getDbType()); |
|
| 39 | + $dbtype=strtolower($this->getDbType()); |
|
| 40 | 40 | foreach(self::$types as $type => $dbtypes) |
| 41 | 41 | { |
| 42 | 42 | if(in_array($dbtype, $dbtypes)) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class TOracleMetaData extends TDbMetaData |
| 27 | 27 | { |
| 28 | - private $_defaultSchema = 'system'; |
|
| 28 | + private $_defaultSchema='system'; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function getSchemaTableName($table) |
| 60 | 60 | { |
| 61 | - if(count($parts= explode('.', str_replace('"','',$table))) > 1) |
|
| 61 | + if(count($parts=explode('.', str_replace('"', '', $table))) > 1) |
|
| 62 | 62 | return array($parts[0], $parts[1]); |
| 63 | 63 | else |
| 64 | - return array($this->getDefaultSchema(),$parts[0]); |
|
| 64 | + return array($this->getDefaultSchema(), $parts[0]); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | protected function createTableInfo($table) |
| 73 | 73 | { |
| 74 | - list($schemaName,$tableName) = $this->getSchemaTableName($table); |
|
| 74 | + list($schemaName, $tableName)=$this->getSchemaTableName($table); |
|
| 75 | 75 | |
| 76 | 76 | // This query is made much more complex by the addition of the 'attisserial' field. |
| 77 | 77 | // The subquery to get that field checks to see if there is an internally dependent |
| 78 | 78 | // sequence on the field. |
| 79 | - $sql = |
|
| 79 | + $sql= |
|
| 80 | 80 | <<<EOD |
| 81 | 81 | SELECT |
| 82 | 82 | a.COLUMN_ID, |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | EOD; |
| 97 | 97 | $this->getDbConnection()->setActive(true); |
| 98 | 98 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
| 99 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 99 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 100 | 100 | //$command->bindValue(':table', $tableName); |
| 101 | 101 | //$command->bindValue(':schema', $schemaName); |
| 102 | - $tableInfo = $this->createNewTableInfo($schemaName, $tableName); |
|
| 102 | + $tableInfo=$this->createNewTableInfo($schemaName, $tableName); |
|
| 103 | 103 | $index=0; |
| 104 | 104 | foreach($command->query() as $col) |
| 105 | 105 | { |
| 106 | - $col['index'] = $index++; |
|
| 106 | + $col['index']=$index++; |
|
| 107 | 107 | $this->processColumn($tableInfo, $col); |
| 108 | 108 | } |
| 109 | 109 | if($index===0) |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | * @param string table name. |
| 117 | 117 | * @return TOracleTableInfo |
| 118 | 118 | */ |
| 119 | - protected function createNewTableInfo($schemaName,$tableName) |
|
| 119 | + protected function createNewTableInfo($schemaName, $tableName) |
|
| 120 | 120 | { |
| 121 | - $info['SchemaName'] = $this->assertIdentifier($schemaName); |
|
| 122 | - $info['TableName'] = $this->assertIdentifier($tableName); |
|
| 123 | - $info['IsView'] = false; |
|
| 124 | - if($this->getIsView($schemaName,$tableName)) $info['IsView'] = true; |
|
| 125 | - list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); |
|
| 126 | - $class = $this->getTableInfoClass(); |
|
| 127 | - return new $class($info,$primary,$foreign); |
|
| 121 | + $info['SchemaName']=$this->assertIdentifier($schemaName); |
|
| 122 | + $info['TableName']=$this->assertIdentifier($tableName); |
|
| 123 | + $info['IsView']=false; |
|
| 124 | + if($this->getIsView($schemaName, $tableName)) $info['IsView']=true; |
|
| 125 | + list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName); |
|
| 126 | + $class=$this->getTableInfoClass(); |
|
| 127 | + return new $class($info, $primary, $foreign); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | if(strpos($name, '"')!==false) |
| 138 | 138 | { |
| 139 | - $ref = 'http://www.oracle.com'; |
|
| 139 | + $ref='http://www.oracle.com'; |
|
| 140 | 140 | throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref); |
| 141 | 141 | } |
| 142 | 142 | return $name; |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | * @param string table name. |
| 148 | 148 | * @return boolean true if the table is a view. |
| 149 | 149 | */ |
| 150 | - protected function getIsView($schemaName,$tableName) |
|
| 150 | + protected function getIsView($schemaName, $tableName) |
|
| 151 | 151 | { |
| 152 | 152 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
| 153 | - $sql = |
|
| 153 | + $sql= |
|
| 154 | 154 | <<<EOD |
| 155 | 155 | select OBJECT_TYPE |
| 156 | 156 | from ALL_OBJECTS |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | and OWNER = '{$schemaName}' |
| 159 | 159 | EOD; |
| 160 | 160 | $this->getDbConnection()->setActive(true); |
| 161 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 161 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 162 | 162 | //$command->bindValue(':schema',$schemaName); |
| 163 | 163 | //$command->bindValue(':table', $tableName); |
| 164 | - return intval($command->queryScalar() === 'VIEW'); |
|
| 164 | + return intval($command->queryScalar()==='VIEW'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -170,17 +170,17 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | protected function processColumn($tableInfo, $col) |
| 172 | 172 | { |
| 173 | - $columnId = strtolower($col['attname']); //use column name as column Id |
|
| 173 | + $columnId=strtolower($col['attname']); //use column name as column Id |
|
| 174 | 174 | |
| 175 | 175 | //$info['ColumnName'] = '"'.$columnId.'"'; //quote the column names! |
| 176 | - $info['ColumnName'] = $columnId; //NOT quote the column names! |
|
| 177 | - $info['ColumnId'] = $columnId; |
|
| 178 | - $info['ColumnIndex'] = $col['index']; |
|
| 179 | - if(! (bool)$col['attnotnull'] ) $info['AllowNull'] = true; |
|
| 180 | - if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey'] = true; |
|
| 181 | - if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey'] = true; |
|
| 182 | - if( (int)$col['atttypmod'] > 0 ) $info['ColumnSize'] = $col['atttypmod']; // - 4; |
|
| 183 | - if( (bool)$col['atthasdef'] ) $info['DefaultValue'] = $col['adsrc']; |
|
| 176 | + $info['ColumnName']=$columnId; //NOT quote the column names! |
|
| 177 | + $info['ColumnId']=$columnId; |
|
| 178 | + $info['ColumnIndex']=$col['index']; |
|
| 179 | + if(!(bool) $col['attnotnull']) $info['AllowNull']=true; |
|
| 180 | + if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey']=true; |
|
| 181 | + if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey']=true; |
|
| 182 | + if((int) $col['atttypmod'] > 0) $info['ColumnSize']=$col['atttypmod']; // - 4; |
|
| 183 | + if((bool) $col['atthasdef']) $info['DefaultValue']=$col['adsrc']; |
|
| 184 | 184 | // |
| 185 | 185 | // For a while Oracle Tables has no associated AutoIncrement Triggers |
| 186 | 186 | // |
@@ -194,31 +194,31 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | */ |
| 197 | - $matches = array(); |
|
| 197 | + $matches=array(); |
|
| 198 | 198 | if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches)) |
| 199 | 199 | { |
| 200 | - $info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/','',$col['type']); |
|
| 200 | + $info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']); |
|
| 201 | 201 | if($this->isPrecisionType($info['DbType'])) |
| 202 | 202 | { |
| 203 | - $info['NumericPrecision'] = intval($matches[1]); |
|
| 203 | + $info['NumericPrecision']=intval($matches[1]); |
|
| 204 | 204 | if(count($matches) > 2) |
| 205 | - $info['NumericScale'] = intval($matches[2]); |
|
| 205 | + $info['NumericScale']=intval($matches[2]); |
|
| 206 | 206 | } |
| 207 | 207 | else |
| 208 | - $info['ColumnSize'] = intval($matches[1]); |
|
| 208 | + $info['ColumnSize']=intval($matches[1]); |
|
| 209 | 209 | } |
| 210 | 210 | else |
| 211 | - $info['DbType'] = $col['type']; |
|
| 212 | - $tableInfo->Columns[$columnId] = new TOracleTableColumn($info); |
|
| 211 | + $info['DbType']=$col['type']; |
|
| 212 | + $tableInfo->Columns[$columnId]=new TOracleTableColumn($info); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @return string serial name if found, null otherwise. |
| 217 | 217 | */ |
| 218 | - protected function getSequenceName($tableInfo,$src) |
|
| 218 | + protected function getSequenceName($tableInfo, $src) |
|
| 219 | 219 | { |
| 220 | - $matches = array(); |
|
| 221 | - if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches)) |
|
| 220 | + $matches=array(); |
|
| 221 | + if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches)) |
|
| 222 | 222 | { |
| 223 | 223 | if(is_int(strpos($matches[1], '.'))) |
| 224 | 224 | return $matches[1]; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | protected function isPrecisionType($type) |
| 234 | 234 | { |
| 235 | - $type = strtolower(trim($type)); |
|
| 235 | + $type=strtolower(trim($type)); |
|
| 236 | 236 | return $type==='number'; // || $type==='interval' || strpos($type, 'time')===0; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
| 248 | 248 | // select decode( a.CONSTRAINT_TYPE, 'P', 'PRIMARY KEY (', 'FOREIGN KEY (' )||b.COLUMN_NAME||')' as consrc, |
| 249 | - $sql = |
|
| 249 | + $sql= |
|
| 250 | 250 | <<<EOD |
| 251 | 251 | select b.COLUMN_NAME as consrc, |
| 252 | 252 | a.CONSTRAINT_TYPE as contype |
@@ -257,24 +257,24 @@ discard block |
||
| 257 | 257 | and a.CONSTRAINT_TYPE in ('P','R') |
| 258 | 258 | EOD; |
| 259 | 259 | $this->getDbConnection()->setActive(true); |
| 260 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 260 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 261 | 261 | //$command->bindValue(':table', $tableName); |
| 262 | 262 | //$command->bindValue(':schema', $schemaName); |
| 263 | - $primary = array(); |
|
| 264 | - $foreign = array(); |
|
| 263 | + $primary=array(); |
|
| 264 | + $foreign=array(); |
|
| 265 | 265 | foreach($command->query() as $row) |
| 266 | 266 | { |
| 267 | - switch( strtolower( $row['contype'] ) ) |
|
| 267 | + switch(strtolower($row['contype'])) |
|
| 268 | 268 | { |
| 269 | 269 | case 'p': |
| 270 | - $primary = array_merge( $primary, array(strtolower( $row['consrc'] )) ); |
|
| 270 | + $primary=array_merge($primary, array(strtolower($row['consrc']))); |
|
| 271 | 271 | /* |
| 272 | 272 | $arr = $this->getPrimaryKeys($row['consrc']); |
| 273 | 273 | $primary = array_merge( $primary, array(strtolower( $arr[0] )) ); |
| 274 | 274 | */ |
| 275 | 275 | break; |
| 276 | 276 | case 'r': |
| 277 | - $foreign = array_merge( $foreign, array(strtolower( $row['consrc'] )) ); |
|
| 277 | + $foreign=array_merge($foreign, array(strtolower($row['consrc']))); |
|
| 278 | 278 | /* |
| 279 | 279 | // if(($fkey = $this->getForeignKeys($row['consrc']))!==null) |
| 280 | 280 | $fkey = $this->getForeignKeys( $row['consrc'] ); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | break; |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | - return array($primary,$foreign); |
|
| 286 | + return array($primary, $foreign); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | protected function getPrimaryKeys($src) |
| 295 | 295 | { |
| 296 | - $matches = array(); |
|
| 296 | + $matches=array(); |
|
| 297 | 297 | if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches)) |
| 298 | - return preg_split('/,\s+/',$matches[1]); |
|
| 298 | + return preg_split('/,\s+/', $matches[1]); |
|
| 299 | 299 | return array(); |
| 300 | 300 | } |
| 301 | 301 | |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | */ |
| 307 | 307 | protected function getForeignKeys($src) |
| 308 | 308 | { |
| 309 | - $matches = array(); |
|
| 310 | - $brackets = '\(([^\)]+)\)'; |
|
| 311 | - $find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
| 309 | + $matches=array(); |
|
| 310 | + $brackets='\(([^\)]+)\)'; |
|
| 311 | + $find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
| 312 | 312 | if(preg_match($find, $src, $matches)) |
| 313 | 313 | { |
| 314 | - $keys = preg_split('/,\s+/', $matches[1]); |
|
| 315 | - $fkeys = array(); |
|
| 314 | + $keys=preg_split('/,\s+/', $matches[1]); |
|
| 315 | + $fkeys=array(); |
|
| 316 | 316 | foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey) |
| 317 | - $fkeys[$keys[$i]] = $fkey; |
|
| 318 | - return array('table' => str_replace('"','',$matches[2]), 'keys' => $fkeys); |
|
| 317 | + $fkeys[$keys[$i]]=$fkey; |
|
| 318 | + return array('table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | { |
| 329 | 329 | foreach($tableInfo->getForeignKeys() as $fk) |
| 330 | 330 | { |
| 331 | - if( $fk==$columnId ) |
|
| 331 | + if($fk==$columnId) |
|
| 332 | 332 | //if(in_array($columnId, array_keys($fk['keys']))) |
| 333 | 333 | return true; |
| 334 | 334 | } |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | WHERE object_type = 'TABLE' AND owner=:schema |
| 358 | 358 | EOD; |
| 359 | 359 | $command=$this->getDbConnection()->createCommand($sql); |
| 360 | - $command->bindParam(':schema',$schema); |
|
| 360 | + $command->bindParam(':schema', $schema); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $rows=$command->queryAll(); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class TPgsqlMetaData extends TDbMetaData |
| 26 | 26 | { |
| 27 | - private $_defaultSchema = 'public'; |
|
| 27 | + private $_defaultSchema='public'; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @return string TDbTableInfo class name. |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function getSchemaTableName($table) |
| 88 | 88 | { |
| 89 | - if(count($parts= explode('.', str_replace('"','',$table))) > 1) |
|
| 89 | + if(count($parts=explode('.', str_replace('"', '', $table))) > 1) |
|
| 90 | 90 | return array($parts[0], $parts[1]); |
| 91 | 91 | else |
| 92 | - return array($this->getDefaultSchema(),$parts[0]); |
|
| 92 | + return array($this->getDefaultSchema(), $parts[0]); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function createTableInfo($table) |
| 101 | 101 | { |
| 102 | - list($schemaName,$tableName) = $this->getSchemaTableName($table); |
|
| 102 | + list($schemaName, $tableName)=$this->getSchemaTableName($table); |
|
| 103 | 103 | |
| 104 | 104 | // This query is made much more complex by the addition of the 'attisserial' field. |
| 105 | 105 | // The subquery to get that field checks to see if there is an internally dependent |
| 106 | 106 | // sequence on the field. |
| 107 | - $sql = |
|
| 107 | + $sql= |
|
| 108 | 108 | <<<EOD |
| 109 | 109 | SELECT |
| 110 | 110 | a.attname, |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | ORDER BY a.attnum |
| 136 | 136 | EOD; |
| 137 | 137 | $this->getDbConnection()->setActive(true); |
| 138 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 138 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 139 | 139 | $command->bindValue(':table', $tableName); |
| 140 | 140 | $command->bindValue(':schema', $schemaName); |
| 141 | - $tableInfo = $this->createNewTableInfo($schemaName, $tableName); |
|
| 141 | + $tableInfo=$this->createNewTableInfo($schemaName, $tableName); |
|
| 142 | 142 | $index=0; |
| 143 | 143 | foreach($command->query() as $col) |
| 144 | 144 | { |
| 145 | - $col['index'] = $index++; |
|
| 145 | + $col['index']=$index++; |
|
| 146 | 146 | $this->processColumn($tableInfo, $col); |
| 147 | 147 | } |
| 148 | 148 | if($index===0) |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | * @param string table name. |
| 156 | 156 | * @return TPgsqlTableInfo |
| 157 | 157 | */ |
| 158 | - protected function createNewTableInfo($schemaName,$tableName) |
|
| 158 | + protected function createNewTableInfo($schemaName, $tableName) |
|
| 159 | 159 | { |
| 160 | - $info['SchemaName'] = $this->assertIdentifier($schemaName); |
|
| 161 | - $info['TableName'] = $this->assertIdentifier($tableName); |
|
| 162 | - if($this->getIsView($schemaName,$tableName)) |
|
| 163 | - $info['IsView'] = true; |
|
| 164 | - list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); |
|
| 165 | - $class = $this->getTableInfoClass(); |
|
| 166 | - return new $class($info,$primary,$foreign); |
|
| 160 | + $info['SchemaName']=$this->assertIdentifier($schemaName); |
|
| 161 | + $info['TableName']=$this->assertIdentifier($tableName); |
|
| 162 | + if($this->getIsView($schemaName, $tableName)) |
|
| 163 | + $info['IsView']=true; |
|
| 164 | + list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName); |
|
| 165 | + $class=$this->getTableInfoClass(); |
|
| 166 | + return new $class($info, $primary, $foreign); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | if(strpos($name, '"')!==false) |
| 177 | 177 | { |
| 178 | - $ref = 'http://www.postgresql.org/docs/7.4/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS'; |
|
| 178 | + $ref='http://www.postgresql.org/docs/7.4/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS'; |
|
| 179 | 179 | throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref); |
| 180 | 180 | } |
| 181 | 181 | return $name; |
@@ -186,19 +186,19 @@ discard block |
||
| 186 | 186 | * @param string table name. |
| 187 | 187 | * @return boolean true if the table is a view. |
| 188 | 188 | */ |
| 189 | - protected function getIsView($schemaName,$tableName) |
|
| 189 | + protected function getIsView($schemaName, $tableName) |
|
| 190 | 190 | { |
| 191 | - $sql = |
|
| 191 | + $sql= |
|
| 192 | 192 | <<<EOD |
| 193 | 193 | SELECT count(c.relname) FROM pg_catalog.pg_class c |
| 194 | 194 | LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) |
| 195 | 195 | WHERE (n.nspname=:schema) AND (c.relkind = 'v'::"char") AND c.relname = :table |
| 196 | 196 | EOD; |
| 197 | 197 | $this->getDbConnection()->setActive(true); |
| 198 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 199 | - $command->bindValue(':schema',$schemaName); |
|
| 198 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 199 | + $command->bindValue(':schema', $schemaName); |
|
| 200 | 200 | $command->bindValue(':table', $tableName); |
| 201 | - return intval($command->queryScalar()) === 1; |
|
| 201 | + return intval($command->queryScalar())===1; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -207,56 +207,56 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function processColumn($tableInfo, $col) |
| 209 | 209 | { |
| 210 | - $columnId = $col['attname']; //use column name as column Id |
|
| 210 | + $columnId=$col['attname']; //use column name as column Id |
|
| 211 | 211 | |
| 212 | - $info['ColumnName'] = '"'.$columnId.'"'; //quote the column names! |
|
| 213 | - $info['ColumnId'] = $columnId; |
|
| 214 | - $info['ColumnIndex'] = $col['index']; |
|
| 212 | + $info['ColumnName']='"'.$columnId.'"'; //quote the column names! |
|
| 213 | + $info['ColumnId']=$columnId; |
|
| 214 | + $info['ColumnIndex']=$col['index']; |
|
| 215 | 215 | if(!$col['attnotnull']) |
| 216 | - $info['AllowNull'] = true; |
|
| 216 | + $info['AllowNull']=true; |
|
| 217 | 217 | if(in_array($columnId, $tableInfo->getPrimaryKeys())) |
| 218 | - $info['IsPrimaryKey'] = true; |
|
| 218 | + $info['IsPrimaryKey']=true; |
|
| 219 | 219 | if($this->isForeignKeyColumn($columnId, $tableInfo)) |
| 220 | - $info['IsForeignKey'] = true; |
|
| 220 | + $info['IsForeignKey']=true; |
|
| 221 | 221 | |
| 222 | 222 | if($col['atttypmod'] > 0) |
| 223 | - $info['ColumnSize'] = $col['atttypmod'] - 4; |
|
| 223 | + $info['ColumnSize']=$col['atttypmod'] - 4; |
|
| 224 | 224 | if($col['atthasdef']) |
| 225 | - $info['DefaultValue'] = $col['adsrc']; |
|
| 226 | - if($col['attisserial'] || substr($col['adsrc'],0,8) === 'nextval(') |
|
| 225 | + $info['DefaultValue']=$col['adsrc']; |
|
| 226 | + if($col['attisserial'] || substr($col['adsrc'], 0, 8)==='nextval(') |
|
| 227 | 227 | { |
| 228 | - if(($sequence = $this->getSequenceName($tableInfo, $col['adsrc']))!==null) |
|
| 228 | + if(($sequence=$this->getSequenceName($tableInfo, $col['adsrc']))!==null) |
|
| 229 | 229 | { |
| 230 | - $info['SequenceName'] = $sequence; |
|
| 230 | + $info['SequenceName']=$sequence; |
|
| 231 | 231 | unset($info['DefaultValue']); |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - $matches = array(); |
|
| 234 | + $matches=array(); |
|
| 235 | 235 | if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches)) |
| 236 | 236 | { |
| 237 | - $info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/','',$col['type']); |
|
| 237 | + $info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']); |
|
| 238 | 238 | if($this->isPrecisionType($info['DbType'])) |
| 239 | 239 | { |
| 240 | - $info['NumericPrecision'] = intval($matches[1]); |
|
| 240 | + $info['NumericPrecision']=intval($matches[1]); |
|
| 241 | 241 | if(count($matches) > 2) |
| 242 | - $info['NumericScale'] = intval($matches[2]); |
|
| 242 | + $info['NumericScale']=intval($matches[2]); |
|
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | - $info['ColumnSize'] = intval($matches[1]); |
|
| 245 | + $info['ColumnSize']=intval($matches[1]); |
|
| 246 | 246 | } |
| 247 | 247 | else |
| 248 | - $info['DbType'] = $col['type']; |
|
| 248 | + $info['DbType']=$col['type']; |
|
| 249 | 249 | |
| 250 | - $tableInfo->Columns[$columnId] = new TPgsqlTableColumn($info); |
|
| 250 | + $tableInfo->Columns[$columnId]=new TPgsqlTableColumn($info); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * @return string serial name if found, null otherwise. |
| 255 | 255 | */ |
| 256 | - protected function getSequenceName($tableInfo,$src) |
|
| 256 | + protected function getSequenceName($tableInfo, $src) |
|
| 257 | 257 | { |
| 258 | - $matches = array(); |
|
| 259 | - if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches)) |
|
| 258 | + $matches=array(); |
|
| 259 | + if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches)) |
|
| 260 | 260 | { |
| 261 | 261 | if(is_int(strpos($matches[1], '.'))) |
| 262 | 262 | return $matches[1]; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | protected function isPrecisionType($type) |
| 272 | 272 | { |
| 273 | - $type = strtolower(trim($type)); |
|
| 273 | + $type=strtolower(trim($type)); |
|
| 274 | 274 | return $type==='numeric' || $type==='interval' || strpos($type, 'time')===0; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | protected function getConstraintKeys($schemaName, $tableName) |
| 284 | 284 | { |
| 285 | - $sql = |
|
| 285 | + $sql= |
|
| 286 | 286 | <<<EOD |
| 287 | 287 | SELECT conname, consrc, contype, indkey, indisclustered FROM ( |
| 288 | 288 | SELECT |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | 1 |
| 331 | 331 | EOD; |
| 332 | 332 | $this->getDbConnection()->setActive(true); |
| 333 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 333 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 334 | 334 | $command->bindValue(':table', $tableName); |
| 335 | 335 | $command->bindValue(':schema', $schemaName); |
| 336 | - $primary = array(); |
|
| 337 | - $foreign = array(); |
|
| 336 | + $primary=array(); |
|
| 337 | + $foreign=array(); |
|
| 338 | 338 | foreach($command->query() as $row) |
| 339 | 339 | { |
| 340 | 340 | switch($row['contype']) |
| 341 | 341 | { |
| 342 | 342 | case 'p': |
| 343 | - $primary = $this->getPrimaryKeys($tableName, $schemaName, $row['indkey']); |
|
| 343 | + $primary=$this->getPrimaryKeys($tableName, $schemaName, $row['indkey']); |
|
| 344 | 344 | break; |
| 345 | 345 | case 'f': |
| 346 | - if(($fkey = $this->getForeignKeys($row['consrc']))!==null) |
|
| 347 | - $foreign[] = $fkey; |
|
| 346 | + if(($fkey=$this->getForeignKeys($row['consrc']))!==null) |
|
| 347 | + $foreign[]=$fkey; |
|
| 348 | 348 | break; |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | - return array($primary,$foreign); |
|
| 351 | + return array($primary, $foreign); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | protected function getPrimaryKeys($tableName, $schemaName, $columnIndex) |
| 360 | 360 | { |
| 361 | - $index = join(', ', explode(' ', $columnIndex)); |
|
| 362 | - $sql = |
|
| 361 | + $index=join(', ', explode(' ', $columnIndex)); |
|
| 362 | + $sql= |
|
| 363 | 363 | <<<EOD |
| 364 | 364 | SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE |
| 365 | 365 | attrelid=( |
@@ -369,14 +369,14 @@ discard block |
||
| 369 | 369 | ) |
| 370 | 370 | AND attnum IN ({$index}) |
| 371 | 371 | EOD; |
| 372 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 372 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 373 | 373 | $command->bindValue(':table', $tableName); |
| 374 | 374 | $command->bindValue(':schema', $schemaName); |
| 375 | 375 | // $command->bindValue(':columnIndex', join(', ', explode(' ', $columnIndex))); |
| 376 | - $primary = array(); |
|
| 376 | + $primary=array(); |
|
| 377 | 377 | foreach($command->query() as $row) |
| 378 | 378 | { |
| 379 | - $primary[] = $row['attname']; |
|
| 379 | + $primary[]=$row['attname']; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | return $primary; |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | protected function getForeignKeys($src) |
| 391 | 391 | { |
| 392 | - $matches = array(); |
|
| 393 | - $brackets = '\(([^\)]+)\)'; |
|
| 394 | - $find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
| 392 | + $matches=array(); |
|
| 393 | + $brackets='\(([^\)]+)\)'; |
|
| 394 | + $find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
| 395 | 395 | if(preg_match($find, $src, $matches)) |
| 396 | 396 | { |
| 397 | - $keys = preg_split('/,\s+/', $matches[1]); |
|
| 398 | - $fkeys = array(); |
|
| 397 | + $keys=preg_split('/,\s+/', $matches[1]); |
|
| 398 | + $fkeys=array(); |
|
| 399 | 399 | foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey) |
| 400 | - $fkeys[$keys[$i]] = $fkey; |
|
| 401 | - return array('table' => str_replace('"','',$matches[2]), 'keys' => $fkeys); |
|
| 400 | + $fkeys[$keys[$i]]=$fkey; |
|
| 401 | + return array('table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | WHERE table_schema=:schema AND table_type='BASE TABLE' |
| 433 | 433 | EOD; |
| 434 | 434 | $command=$this->getDbConnection()->createCommand($sql); |
| 435 | - $command->bindParam(':schema',$schema); |
|
| 435 | + $command->bindParam(':schema', $schema); |
|
| 436 | 436 | $rows=$command->queryAll(); |
| 437 | 437 | $names=array(); |
| 438 | 438 | foreach($rows as $row) |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function getPHPType() |
| 37 | 37 | { |
| 38 | - $dbtype = strtolower($this->getDbType()); |
|
| 38 | + $dbtype=strtolower($this->getDbType()); |
|
| 39 | 39 | foreach(self::$types as $type => $dbtypes) |
| 40 | 40 | { |
| 41 | 41 | if(in_array($dbtype, $dbtypes)) |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function getSearchExpression($fields, $keywords) |
| 32 | 32 | { |
| 33 | - $columns = array(); |
|
| 33 | + $columns=array(); |
|
| 34 | 34 | foreach($fields as $field) |
| 35 | 35 | { |
| 36 | 36 | if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
| 37 | - $columns[] = $field; |
|
| 37 | + $columns[]=$field; |
|
| 38 | 38 | } |
| 39 | 39 | return parent::getSearchExpression($columns, $keywords); |
| 40 | 40 | } |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected function isSearchableColumn($column) |
| 46 | 46 | { |
| 47 | - $type = strtolower($column->getDbType()); |
|
| 48 | - return $type === 'character varying' || $type === 'varchar' || |
|
| 49 | - $type === 'character' || $type === 'char' || $type === 'text'; |
|
| 47 | + $type=strtolower($column->getDbType()); |
|
| 48 | + return $type==='character varying' || $type==='varchar' || |
|
| 49 | + $type==='character' || $type==='char' || $type==='text'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $conditions=array(); |
| 61 | 61 | foreach($words as $word) |
| 62 | - $conditions[] = $column.' ILIKE '.$this->getDbConnection()->quoteString('%'.$word.'%'); |
|
| 62 | + $conditions[]=$column.' ILIKE '.$this->getDbConnection()->quoteString('%'.$word.'%'); |
|
| 63 | 63 | return '('.implode(' AND ', $conditions).')'; |
| 64 | 64 | } |
| 65 | 65 | |