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


PHP JDate::sub方法代码示例

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


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

示例1: getStartedSoonProjects

 /**
  * Get the number of started soon projects.
  *
  * <code>
  * $options = array(
  *     "interval" => 7, // The number of last days when the campaigns have been started.
  *     "state"    => 1, // The state of the campaign - published or unpublished.
  *     "approved" => 1, // The approved state - approved or not approved.
  * );
  *
  * $statistics   = new Crowdfunding\Statistics\Basic(\JFactory::getDbo());
  * $numberOfProjects = $statistics->getStartedSoonProjects();
  * </code>
  *
  * @param array $options Options used to be aggregated data.
  *
  * @return int
  */
 public function getStartedSoonProjects($options = array())
 {
     $query = $this->db->getQuery(true);
     $query->select('COUNT(*)')->from($this->db->quoteName('#__crowdf_projects', 'a'));
     // Filter by date interval.
     if (array_key_exists('interval', $options)) {
         $days = (int) $options['interval'];
         if ($days > 0) {
             jimport('joomla.date.date');
             $date = new \JDate();
             $today = $date->toSql();
             $date->sub(new \DateInterval('P' . $days . 'D'));
             $query->where('a.funding_start >= ' . $this->db->quote($date->toSql()) . ' AND a.funding_start <= ' . $this->db->quote($today));
         }
     }
     // Prepare filters.
     $this->prepareFilters($query, $options);
     $this->db->setQuery($query);
     return (int) $this->db->loadResult();
 }
开发者ID:sis-direct,项目名称:CrowdFunding,代码行数:38,代码来源:Basic.php

示例2: prepareFilterDate

 /**
  * Prepare filter by date.
  *
  * @param JDatabaseQuery $query
  */
 protected function prepareFilterDate(&$query)
 {
     $db = $this->getDbo();
     // Filter by date.
     $filter = (int) $this->getState($this->context . '.filter_date');
     switch ($filter) {
         case 1:
             // Starting soon
             jimport('joomla.date.date');
             $date = new JDate();
             $today = $date->toSql();
             $date->sub(new DateInterval('P7D'));
             $query->where('a.funding_start >= ' . $db->quote($date->toSql()) . ' AND a.funding_start <= ' . $db->quote($today));
             break;
         case 2:
             // Ending soon
             jimport('joomla.date.date');
             $date = new JDate();
             $today = $date->toSql();
             $date->add(new DateInterval('P7D'));
             $query->where('a.funding_end >= ' . $db->quote($today) . ' AND a.funding_start <= ' . $db->quote($date->toSql()));
             break;
     }
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:29,代码来源:category.php

示例3: getStartedSoonProjects

 /**
  * Get the number of started soon projects.
  *
  * <code>
  * $options = array(
  *     "interval" => 7, // The number of last days when the campaigns have been started.
  *     "state"    => 1, // The state of the campaign - published or unpublished.
  *     "approved" => 1, // The approved state - approved or not approved.
  * );
  *
  * $statistics   = new Crowdfunding\Statistics\Basic(\JFactory::getDbo());
  * $numberOfProjects = $statistics->getStartedSoonProjects();
  * </code>
  *
  * @param array $options Options used to be aggregated data.
  *
  * @return int
  */
 public function getStartedSoonProjects($options = array())
 {
     $query = $this->db->getQuery(true);
     $query->select("COUNT(*)")->from($this->db->quoteName("#__crowdf_projects", "a"));
     // Filter by date interval.
     if (isset($options["interval"])) {
         $days = (int) $options["interval"];
         if ($days > 0) {
             jimport("joomla.date.date");
             $date = new \JDate();
             $today = $date->toSql();
             $date->sub(new \DateInterval("P" . $days . "D"));
             $query->where("a.funding_start >= " . $this->db->quote($date->toSql()) . " AND a.funding_start <= " . $this->db->quote($today));
         }
     }
     // Prepare filters.
     $this->prepareFilters($query, $options);
     $this->db->setQuery($query);
     $result = $this->db->loadResult();
     if (!$result) {
         $result = 0;
     }
     return $result;
 }
开发者ID:Eautentik,项目名称:CrowdFunding,代码行数:42,代码来源:Basic.php


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