Exemplo n.º 1
0
 /**
  * Build a single where clause. This is a compare of a column to a value with a given operator.
  * Based on the operator the string is hopefully correctly build. It is up to the client to
  * connect these single clauses with boolean operator for a complete where clause.
  *
  * @param string $tableAlias database tablename or alias
  * @param string $operator operator constant
  * @param string $col name of column
  * @param string $value value to compare to
  */
 function setSingleWhereField($tableAlias, $operator, $col, $value)
 {
     $where = '';
     switch ($operator) {
         case OP_NOTIN_INT:
         case OP_IN_INT:
             $value = implode(',', tx_rnbase_util_Strings::intExplode(',', $value));
             $where .= $tableAlias . '.' . strtolower($col) . ' ' . $operator . ' (' . $value . ')';
             break;
         case OP_NOTIN:
         case OP_IN:
             $values = tx_rnbase_util_Strings::trimExplode(',', $value);
             for ($i = 0, $cnt = count($values); $i < $cnt; $i++) {
                 $values[$i] = $GLOBALS['TYPO3_DB']->fullQuoteStr($values[$i], $tableAlias);
             }
             $value = implode(',', $values);
             $where .= $tableAlias . '.' . strtolower($col) . ' ' . ($operator == OP_IN ? 'IN' : 'NOT IN') . ' (' . $value . ')';
             break;
         case OP_NOTIN_SQL:
         case OP_IN_SQL:
             $where .= $tableAlias . '.' . strtolower($col) . ' ' . ($operator == OP_IN_SQL ? 'IN' : 'NOT IN') . ' (' . $value . ')';
             break;
         case OP_INSET_INT:
             // Values splitten und einzelne Abfragen mit OR verbinden
             $where = $this->searchWhere($value, $tableAlias . '.' . strtolower($col), 'FIND_IN_SET_OR');
             break;
         case OP_EQ:
             $where .= $tableAlias . '.' . strtolower($col) . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_NOTEQ:
             $where .= $tableAlias . '.' . strtolower($col) . ' != ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_LT:
             $where .= $tableAlias . '.' . strtolower($col) . ' < ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_LTEQ:
             $where .= $tableAlias . '.' . strtolower($col) . ' <= ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_GT:
             $where .= $tableAlias . '.' . strtolower($col) . ' > ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_GTEQ:
             $where .= $tableAlias . '.' . strtolower($col) . ' >= ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias);
             break;
         case OP_EQ_INT:
         case OP_NOTEQ_INT:
         case OP_GT_INT:
         case OP_LT_INT:
         case OP_GTEQ_INT:
         case OP_LTEQ_INT:
             $where .= $tableAlias . '.' . strtolower($col) . ' ' . $operator . ' ' . intval($value);
             break;
         case OP_EQ_NOCASE:
             $where .= 'lower(' . $tableAlias . '.' . strtolower($col) . ') = lower(' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $tableAlias) . ')';
             break;
         case OP_LIKE:
             // Stringvergleich mit LIKE
             $where .= $this->searchWhere($value, $tableAlias . '.' . strtolower($col));
             break;
         case OP_LIKE_CONST:
             $where .= $this->searchWhere($value, $tableAlias . '.' . strtolower($col), OP_LIKE_CONST);
             break;
         default:
             tx_rnbase_util_Misc::mayday('Unknown Operator for comparation defined: ' . $operator);
     }
     return $where . ' ';
 }
 /**
  * Removes dam references. If no parameter is given, all references will be removed.
  *
  * @param string $uids commaseperated uids
  */
 public static function deleteReferences($tableName, $fieldName, $itemId, $uids = '')
 {
     $where = 'tablenames=' . tx_rnbase_util_DB::fullQuoteStr($tableName, 'tx_dam_mm_ref');
     $where .= ' AND ident=' . tx_rnbase_util_DB::fullQuoteStr($fieldName, 'tx_dam_mm_ref');
     $where .= ' AND uid_foreign=' . (int) $itemId;
     if (strlen(trim($uids))) {
         $uids = implode(',', tx_rnbase_util_Strings::intExplode(',', $uids));
         $where .= ' AND uid_local IN (' . $uids . ') ';
     }
     tx_rnbase_util_DB::doDelete('tx_dam_mm_ref', $where);
     // Jetzt die Bildanzahl aktualisieren
     self::updateImageCount($tableName, $fieldName, $itemId);
 }
 /**
  * Umwandlung eines Zeitstrings yyyy-mm-dd H:i:s in einen Timestamp
  *
  * @param string $datetime Format: yyyy-mm-dd H:i:s
  * @return int
  */
 static function datetime_mysql2tstamp($datetime, $timezone = 'CET')
 {
     list($datum, $zeit) = explode(' ', $datetime);
     list($jahr, $monat, $tag) = tx_rnbase_util_Strings::intExplode('-', $datum);
     list($std, $min, $sec) = $zeit ? tx_rnbase_util_Strings::intExplode(':', $zeit) : array(0, 0, 0);
     return self::getTimeStamp($jahr, $monat, $tag, $std, $min, $sec, $timezone);
 }