예제 #1
0
 /**
  * Returns the next available row or false.
  *
  * @return mixed The associative array or false.
  */
 public function next()
 {
     $this->current = $row = $this->db->sql_fetch_assoc($this->resource);
     if ($row === false) {
         $this->countDone = true;
     } else {
         $this->count++;
     }
     return $row;
 }
예제 #2
0
 /**
  * Check if there are still resources left for the process with the given id
  * Used to determine timeouts and to ensure a proper cleanup if there's a timeout
  *
  * @param  string  identification string for the process
  * @return boolean determines if the process is still active / has resources
  */
 function CLI_checkIfProcessIsActive($pid)
 {
     $ret = false;
     $this->db->sql_query('BEGIN');
     $res = $this->db->exec_SELECTquery('process_id,active,ttl', 'tx_crawler_process', 'process_id = \'' . $pid . '\'  AND deleted=0', '', 'ttl', '0,1');
     if ($row = $this->db->sql_fetch_assoc($res)) {
         $ret = intVal($row['active']) == 1;
     }
     $this->db->sql_query('COMMIT');
     return $ret;
 }
 /**
  * Clear the TYPO3 page cache for the given record.
  * If the record lies on a page, then we clear the cache of this page.
  * If the record has no PID column, we clear the cache of the current page as best-effort.
  *
  * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user.
  *
  * @param $tableName Table name of the record
  * @param $uid UID of the record
  * @return void
  */
 protected function clearPageCache($tableName, $uid)
 {
     $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration();
     if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') {
     } else {
         // if disabled, return
         return;
     }
     $pageIdsToClear = array();
     $storagePage = NULL;
     $columns = $this->databaseHandle->admin_get_fields($tableName);
     if (array_key_exists('pid', $columns)) {
         $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . intval($uid));
         if ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
             $storagePage = $row['pid'];
             $pageIdsToClear[] = $storagePage;
         }
     } elseif (isset($GLOBALS['TSFE'])) {
         // No PID column - we can do a best-effort to clear the cache of the current page if in FE
         $storagePage = $GLOBALS['TSFE']->id;
         $pageIdsToClear[] = $storagePage;
     }
     if ($storagePage === NULL) {
         return;
     }
     if (!isset($this->pageTSConfigCache[$storagePage])) {
         $this->pageTSConfigCache[$storagePage] = t3lib_BEfunc::getPagesTSconfig($storagePage);
     }
     if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
         $clearCacheCommands = t3lib_div::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), 1);
         $clearCacheCommands = array_unique($clearCacheCommands);
         foreach ($clearCacheCommands as $clearCacheCommand) {
             if (t3lib_div::testInt($clearCacheCommand)) {
                 $pageIdsToClear[] = $clearCacheCommand;
             }
         }
     }
     // TODO check if we can hand this over to the Dispatcher to clear the page only once, this will save around 10% time while inserting and updating
     Tx_Extbase_Utility_Cache::clearPageCache($pageIdsToClear);
 }
 /**
  * Directly execute a query on the db and return the result.
  *
  * @param string $query The query.
  * @param mixed $result If set to false, no result is returned. If set to true, an array with the rows is returned. If set to a string, an associated array is returned, where the $row[$result] is used as the key.
  * @return array The assoc return array.
  * @internal
  */
 public function _sql($query, $result = true)
 {
     $resource = $this->db->sql_query($query);
     if ($resource === null) {
         // mysqli 6.2
         return;
     }
     if ($result === false) {
         if ($resource !== null) {
             $this->db->sql_free_result($resource);
         }
         return;
     }
     if ($resource === null) {
         return array();
     }
     $output = array();
     if ($result === true) {
         while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
             $output[] = $row;
         }
     } else {
         $result = (string) $result;
         while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
             $output[$row[$result]] = $row;
         }
     }
     $this->db->sql_free_result($resource);
     return $output;
 }