Example #1
0
 /**
  * Returns a value from the current archive with the name = $name
  * Method used by getNumeric or getBlob
  *
  * @param string $name
  * @param string $typeValue     numeric|blob
  * @param string|bool $archivedDate  Value to store date of archive info in. If false, not stored.
  * @return mixed|bool  false if no result
  */
 protected function get($name, $typeValue = 'numeric', &$archivedDate = false)
 {
     $this->setRequestedReport($name);
     $this->prepareArchive();
     // values previously "get" and now cached
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric && isset($this->numericCached[$name])) {
         return $this->numericCached[$name];
     }
     // During archiving we prefetch the blobs recursively
     // and we get them faster from memory after
     if ($typeValue == 'blob' && isset($this->blobCached[$name])) {
         return $this->blobCached[$name];
     }
     if ($name == 'idarchive') {
         return $this->idArchive;
     }
     if (!$this->isThereSomeVisits) {
         return false;
     }
     // select the table to use depending on the type of the data requested
     switch ($typeValue) {
         case 'blob':
             $table = $this->archiveProcessing->getTableArchiveBlobName();
             break;
         case 'numeric':
         default:
             $table = $this->archiveProcessing->getTableArchiveNumericName();
             break;
     }
     $db = Zend_Registry::get('db');
     $row = $db->fetchRow("SELECT value, ts_archived\n\t\t\t\t\t\t\t\tFROM {$table}\n\t\t\t\t\t\t\t\tWHERE idarchive = ? AND name = ?", array($this->idArchive, $name));
     $value = $tsArchived = false;
     if (is_array($row)) {
         $value = $row['value'];
         $tsArchived = $row['ts_archived'];
     }
     if ($archivedDate !== false) {
         $archivedDate = $tsArchived;
     }
     if ($value === false) {
         if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
             $this->numericCached[$name] = false;
         }
         return $value;
     }
     // uncompress when selecting from the BLOB table
     if ($typeValue == 'blob' && $db->hasBlobDataType()) {
         $value = $this->uncompress($value);
     }
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
         $this->numericCached[$name] = $value;
     }
     return $value;
 }
Example #2
0
 /**
  * Returns a value from the current archive with the name = $name 
  * Method used by getNumeric or getBlob
  *
  * @param string $name
  * @param string $typeValue numeric|blob
  * @return mixed|false if no result
  */
 protected function get($name, $typeValue = 'numeric')
 {
     // values previously "get" and now cached
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric && isset($this->numericCached[$name])) {
         return $this->numericCached[$name];
     }
     // During archiving we prefetch the blobs recursively
     // and we get them faster from memory after
     if ($typeValue == 'blob' && isset($this->blobCached[$name])) {
         return $this->blobCached[$name];
     }
     $this->prepareArchive();
     if ($name == 'idarchive') {
         return $this->idArchive;
     }
     //		Piwik::log("-- get '$name'");
     if (!$this->isThereSomeVisits) {
         return false;
     }
     // select the table to use depending on the type of the data requested
     switch ($typeValue) {
         case 'blob':
             $table = $this->archiveProcessing->getTableArchiveBlobName();
             break;
         case 'numeric':
         default:
             $table = $this->archiveProcessing->getTableArchiveNumericName();
             break;
     }
     // we select the requested value
     $db = Zend_Registry::get('db');
     $value = $db->fetchOne("SELECT value \n\t\t\t\t\t\t\t\tFROM {$table}\n\t\t\t\t\t\t\t\tWHERE idarchive = ?\n\t\t\t\t\t\t\t\t\tAND name = ?", array($this->idArchive, $name));
     // no result, returns false
     if ($value === false) {
         if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
             // we cache the results
             $this->numericCached[$name] = false;
         }
         return $value;
     }
     // uncompress when selecting from the BLOB table
     if ($typeValue == 'blob') {
         $value = gzuncompress($value);
     }
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
         // we cache the results
         $this->numericCached[$name] = $value;
     }
     return $value;
 }
Example #3
0
 /**
  * Returns a value from the current archive with the name = $name 
  * Method used by getNumeric or getBlob
  *
  * @param string $name
  * @param string $typeValue numeric|blob
  * @return mixed|false if no result
  */
 protected function get($name, $typeValue = 'numeric')
 {
     // values previously "get" and now cached
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric && isset($this->numericCached[$name])) {
         return $this->numericCached[$name];
     }
     // During archiving we prefetch the blobs recursively
     // and we get them faster from memory after
     if ($typeValue == 'blob' && isset($this->blobCached[$name])) {
         return $this->blobCached[$name];
     }
     if ($name == 'idarchive') {
         return $this->idArchive;
     }
     if (!$this->isThereSomeVisits) {
         return false;
     }
     // select the table to use depending on the type of the data requested
     switch ($typeValue) {
         case 'blob':
             $table = $this->archiveProcessing->getTableArchiveBlobName();
             break;
         case 'numeric':
         default:
             $table = $this->archiveProcessing->getTableArchiveNumericName();
             break;
     }
     $db = Zend_Registry::get('db');
     $value = $db->fetchOne("/* SHARDING_ID_SITE = " . $this->site->getId() . " */  SELECT value \n\t\t\t\t\t\t\t\tFROM {$table}\n\t\t\t\t\t\t\t\tWHERE idarchive = ?\n\t\t\t\t\t\t\t\t\tAND name = ?", array($this->idArchive, $name));
     if ($value === false) {
         if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
             $this->numericCached[$name] = false;
         }
         return $value;
     }
     if ($typeValue == 'numeric' && $this->cacheEnabledForNumeric) {
         $this->numericCached[$name] = $value;
     }
     return $value;
 }