Example #1
0
 /**
  * Recupera il contenuto del Log da $from a $to.
  * 
  * @param $from: data TimeStamp da cui selezionare le entry del Log. Se 0 parte dall'inizio.
  * @param $to: data TimeStamp in cui finire la selezione delle entry del Log. Se 0 arriva fino alla fine.
  * @return: array contenente tutte le entry.
  */
 static function getLog($from, $to)
 {
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineLogColumns();
         $table = Query::getDBSchema()->getTable(TABLE_LOG);
         $s = "";
         if (is_numeric($from) && $from != 0) {
             $s1 = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(LOG_TIMESTAMP), Operator::GREATEROREQUAL, $from)), array());
         }
         if (is_numeric($to) && $to != 0) {
             $s2 = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(LOG_TIMESTAMP), Operator::LESSEROREQUAL, $to)), array("order" => 1, "by" => LOG_TIMESTAMP));
         }
         if (is_numeric($from) && $from != 0 && is_numeric($to) && $to != 0) {
             $s = Query::generateComplexSelectStm(array($s1, $s2), array(SelectOperator::INTERSECT));
         } else {
             if (is_numeric($from) && $from != 0) {
                 $s = $s1;
             } else {
                 if (is_numeric($to) && $to != 0) {
                     $s = $s2;
                 } else {
                     return array();
                 }
             }
         }
         //echo "<br />" . $s; //DEBUG
         $rs = $db->execute($s, $table->getName(), LOGMANAGER);
         $log_result = array();
         if ($db->num_rows() > 0) {
             while ($row = mysql_fetch_row) {
                 $log_result[] = $row;
             }
             //echo "<br />" . serialize($log_result); //DEBUG
             return $log_result;
         } else {
             $db->display_error("LogManager::getLog()");
         }
     } else {
         $db->display_connect_error("LogManager::getLog()");
     }
     return array();
 }