Changeset 17758 for extensions/EStat/lib/statDBMonth.class.inc.php
- Timestamp:
- Sep 5, 2012, 4:15:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/EStat/lib/statDBMonth.class.inc.php
r17737 r17758 78 78 * 79 79 * missing values are set to default value 80 * country is defined automatically after buildIPCountry call; set to '' while 81 * call is not made 80 82 * 81 83 * @param Array $log : a record … … 109 111 // insert log 110 112 $sql="INSERT INTO logs 111 (date, IPadress, userId, catId, imageId, tagsId, section,113 (date, IPadress, country, userId, catId, imageId, tagsId, section, 112 114 userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion, 113 115 uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH) … … 115 117 //"'".$this->dbHandle->escapeString($value['IPadress'])."', ". 116 118 ":IP, ". 119 "'', ". 117 120 $value['userId'].", ". 118 121 $value['catId'].", ". … … 254 257 if(!isset($filter['uaType'])) $filter['uaType']=null; 255 258 259 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 256 260 // check filter values - getOperator check and 'clean' the filter 257 261 $filter['date']=$this->getOperator($filter['date'], 'date'); … … 296 300 array('id'=>'id', 'direction'=>'A') 297 301 ); 302 // to optimize query, if date is the first field selected for order by, 303 // all other fields are removed; exception: if IPadress is the second one this 304 // field is kept 305 $tmp=$orderBy; 306 if($tmp[0]['id']=='date') 307 { 308 $orderBy=array($tmp[0]); 309 if($tmp[1]['id']=='IPadress') 310 { 311 $orderBy[]=$tmp[1]; 312 } 313 } 314 298 315 //build ORDER BY clause 299 316 $orderBy=$this->buildOrderByClause($orderBy); … … 310 327 { 311 328 case ASDF_GET_ROWS: 312 $sql="SELECT id, date, IPadress, userId, catId, imageId, tagsId, section,329 $sql="SELECT id, date, IPadress, country, userId, catId, imageId, tagsId, section, 313 330 userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion, 314 331 uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH 315 332 FROM logs $where $orderBy $limit;"; 333 316 334 $sqlStm=$this->dbHandle->prepare($sql); 317 335 foreach($IPList as $num=>$IP) … … 576 594 if(!isset($filter['country'])) $filter['country']=null; 577 595 596 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 578 597 // check filter values - getOperator check and 'clean' the filter 579 598 $filter['IPadress']=$this->getOperator($filter['IPadress'], 'IP'); … … 1248 1267 DROP TABLE IF EXISTS tmpIp; 1249 1268 1269 -- update the logs table for rows with unset country 1270 -- use a simple sub select here, assuming that it's quick enough for the update 1271 UPDATE logs 1272 SET country=(SELECT sip.country FROM statip sip WHERE logs.IPadress = sip.IPadress) 1273 WHERE country=''; 1274 1250 1275 -- commit changes 1251 1276 COMMIT TRANSACTION; … … 1285 1310 'date' INTEGER, 1286 1311 'IPadress' BLOB, 1312 'country' TEXT, 1287 1313 'userId' INTEGER, 1288 1314 'catId' INTEGER, … … 1302 1328 );" 1303 1329 ); 1304 $this->dbHandle->exec("CREATE INDEX iDate ON logs ('date');"); 1305 $this->dbHandle->exec("CREATE INDEX iByIP ON logs ('IPadress');"); 1330 $this->dbHandle->exec("CREATE INDEX iDateIP ON logs ('date', 'IPadress');"); 1331 $this->dbHandle->exec("CREATE INDEX iIPCountry ON logs ('IPadress', 'country');"); 1332 $this->dbHandle->exec("CREATE INDEX iUAB ON logs ('uaType', 'uaBrowser', 'uaEngine');"); 1333 $this->dbHandle->exec("CREATE INDEX iUAO ON logs ('uaOS');"); 1306 1334 } 1307 1335
Note: See TracChangeset
for help on using the changeset viewer.