コード例 #1
0
ファイル: class.tx_crawler_lib.php プロジェクト: b13/crawler
 /**
  * This method determines duplicates for a queue entry with the same parameters and this timestamp.
  * If the timestamp is in the past, it will check if there is any unprocessed queue entry in the past.
  * If the timestamp is in the future it will check, if the queued entry has exactly the same timestamp
  *
  * @param int $tstamp
  * @param string $parameters
  * @author Fabrizio Branca
  * @author Timo Schmidt
  * @return array;
  */
 protected function getDuplicateRowsIfExist($tstamp, $fieldArray)
 {
     $rows = array();
     $currentTime = $this->getCurrentTime();
     //if this entry is scheduled with "now"
     if ($tstamp <= $currentTime) {
         if ($this->extensionSettings['enableTimeslot']) {
             $timeBegin = $currentTime - 100;
             $timeEnd = $currentTime + 100;
             $where = ' ((scheduled BETWEEN ' . $timeBegin . ' AND ' . $timeEnd . ' ) OR scheduled <= ' . $currentTime . ') ';
         } else {
             $where = 'scheduled <= ' . $currentTime;
         }
     } elseif ($tstamp > $currentTime) {
         //entry with a timestamp in the future need to have the same schedule time
         $where = 'scheduled = ' . $tstamp;
     }
     if (!empty($where)) {
         $result = $this->db->exec_SELECTgetRows('qid', 'tx_crawler_queue', $where . ' AND NOT exec_time' . ' AND NOT process_id ' . ' AND page_id=' . intval($fieldArray['page_id']) . ' AND parameters_hash = ' . $this->db->fullQuoteStr($fieldArray['parameters_hash'], 'tx_crawler_queue'));
         if (is_array($result)) {
             foreach ($result as $value) {
                 $rows[] = $value['qid'];
             }
         }
     }
     return $rows;
 }
コード例 #2
0
 /**
  * Replace query placeholders in a query part by the given
  * parameters.
  *
  * @param string $sqlString The query part with placeholders
  * @param array $parameters The parameters
  * @return string The query part with replaced placeholders
  */
 protected function replacePlaceholders(&$sqlString, array $parameters)
 {
     // TODO profile this method again
     if (substr_count($sqlString, '?') !== count($parameters)) {
         throw new Tx_Extbase_Persistence_Exception('The number of question marks to replace must be equal to the number of parameters.', 1242816074);
     }
     $offset = 0;
     foreach ($parameters as $parameter) {
         $markPosition = strpos($sqlString, '?', $offset);
         if ($markPosition !== FALSE) {
             if ($parameter === NULL) {
                 $parameter = 'NULL';
             } elseif (is_array($parameter) || $parameter instanceof ArrayAccess || $parameter instanceof Traversable) {
                 $items = array();
                 foreach ($parameter as $item) {
                     $items[] = $this->databaseHandle->fullQuoteStr($item, 'foo');
                 }
                 $parameter = '(' . implode(',', $items) . ')';
             } else {
                 $parameter = $this->databaseHandle->fullQuoteStr($parameter, 'foo');
                 // FIXME This may not work with DBAL; check this
             }
             $sqlString = substr($sqlString, 0, $markPosition) . $parameter . substr($sqlString, $markPosition + 1);
         }
         $offset = $markPosition + strlen($parameter);
     }
 }
コード例 #3
0
 /**
  * Creates a where condition with the resolved relations to find the associated sys_log entries.
  *
  * @return string The generated where.
  */
 protected function _getSysLogWhere()
 {
     $whereParts = array();
     foreach ($this->resolvedRelations as $table => &$tableData) {
         if (substr($table, 0, 2) !== '__' && !empty($tableData)) {
             $uids = array_filter(array_keys($tableData), 'is_numeric');
             $uids = empty($uids) ? array(0) : $uids;
             $whereParts[] = '(sys_log.tablename = ' . $this->db->fullQuoteStr($table, 'sys_log') . ' AND sys_log.recuid IN (' . implode(',', $uids) . '))';
         }
     }
     if (count($whereParts) === 0) {
         return '1 = 0';
     }
     return implode(' OR ', $whereParts);
 }