当前位置: 首页>>代码示例>>PHP>>正文


PHP FabrikWorker::specialStrToMySQL方法代码示例

本文整理汇总了PHP中FabrikWorker::specialStrToMySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::specialStrToMySQL方法的具体用法?PHP FabrikWorker::specialStrToMySQL怎么用?PHP FabrikWorker::specialStrToMySQL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FabrikWorker的用法示例。


在下文中一共展示了FabrikWorker::specialStrToMySQL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRangedFilterValue

 /**
  * This builds an array containing the filters value and condition
  * when using a ranged search
  *
  * @param   array  $value     Initial value
  * @param   string $condition Filter condition e.g BETWEEN
  *
  * @return  array  (value condition)
  */
 protected function getRangedFilterValue($value, $condition = '')
 {
     $db = FabrikWorker::getDbo();
     $params = $this->getParams();
     /* $$$ hugh - need to convert dates to MySQL format for the query
      * $$$ hugh - not any more, since we changed to always submit in MySQL format
      * $$$ hugh - removing the MySQL conversion has broken 'special' range handling,
      * which used to happen in the MySQL conversion function.  So ...
      * Created new helper function specialStrToMySQL() which turns things
      * like 'midnight yesterday' etc. into MySQL dates, defaulting to GMT.
      * This lets us do ranged query string and content plugin filters like ...
      * table___date[value][]=midnight%20yesterday&table___date[value][]=midnight%20today&table___date[condition]=BETWEEN
      */
     $value[0] = FabrikWorker::specialStrToMySQL(FArrayHelper::getValue($value, 0));
     $value[1] = FabrikWorker::specialStrToMySQL(FArrayHelper::getValue($value, 1));
     // $$$ hugh - if the first date is later than the second, swap 'em round  to keep 'BETWEEN' in the query happy
     if (strtotime($value[0]) > strtotime($value[1])) {
         $tmp_value = $value[0];
         $value[0] = $value[1];
         $value[1] = $tmp_value;
     }
     $exactTime = $this->formatContainsTime($params->get('date_table_format'));
     if (!$params->get('date_showtime', 0) || $exactTime == false) {
         // Range values could already have been set in getFilterValue
         if (!$this->rangeFilterSet) {
             /* $$$ due to some changes in how we handle ranges, the following was no longer getting
              * applied in getFilterValue, needed because on first submit of a filter an arbitrary time
              * is being set (i.e. time "now").
              */
             $value[0] = $this->setMySQLTimeToZero($value[0]);
             $value[1] = $this->setMySQLTimeToZero($value[1]);
             /* $$$ hugh - need to back this out by one second, otherwise we're including next day.
              * So ... say we are searching from '2009-07-17' to '2009-07-21', the
              * addDays(1) changes '2009-07-21 00:00:00' to '2009-07-22 00:00:00',
              * but what we really want is '2009-07-21 23:59:59'
              */
             $value[1] = date("Y-m-d H:i:s", strtotime($this->addDays($value[1], 1)) - 1);
         }
     }
     // $$$ rob 20/07/2012 Date is posted as local time, need to set it back to GMT. Seems needed even if dates are saved without timeselector
     // $$$ hugh - think we may need to take 'store as local' in to account here?
     $localTimeZone = new DateTimeZone($this->config->get('offset'));
     $params = $this->getParams();
     $storeAsLocal = $params->get('date_store_as_local', '0') == '1';
     $date = JFactory::getDate($value[0], $localTimeZone);
     $value[0] = $date->toSql($storeAsLocal);
     $date = JFactory::getDate($value[1], $localTimeZone);
     /* $$$ hugh - why are we setting the 'local' arg on toSql() for end date but not the start date of the range?
      * This ends up with queries like "BETWEEN '2012-01-26 06:00:00' AND '2012-01-26 23:59:59'"
      * with CST (GMT -6), which chops out 6 hours of the day range.
      * Also, see comment above about maybe needing to take "save as local" in to account on this.
      */
     // $value[1] = $date->toSql(true);
     $value[1] = $date->toSql($storeAsLocal);
     $value = $db->quote($value[0]) . ' AND ' . $db->quote($value[1]);
     $condition = 'BETWEEN';
     return array($value, $condition);
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:67,代码来源:date.php


注:本文中的FabrikWorker::specialStrToMySQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。