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


PHP JDatabaseQuery::format方法代码示例

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


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

示例1: testFormat

 /**
  * Tests the JDatabaseQuery::format method.
  *
  * @return  void
  *
  * @since   12.3
  */
 public function testFormat()
 {
     $result = $this->_instance->format('SELECT %n FROM %n WHERE %n = %a', 'foo', '#__bar', 'id', 10);
     $expected = 'SELECT ' . $this->_instance->qn('foo') . ' FROM ' . $this->_instance->qn('#__bar') . ' WHERE ' . $this->_instance->qn('id') . ' = 10';
     $this->assertThat($result, $this->equalTo($expected), 'Line: ' . __LINE__ . '.');
     $result = $this->_instance->format('SELECT %n FROM %n WHERE %n = %t OR %3$n = %Z', 'id', '#__foo', 'date');
     $expected = 'SELECT ' . $this->_instance->qn('id') . ' FROM ' . $this->_instance->qn('#__foo') . ' WHERE ' . $this->_instance->qn('date') . ' = ' . $this->_instance->currentTimestamp() . ' OR ' . $this->_instance->qn('date') . ' = ' . $this->_instance->nullDate(true);
     $this->assertThat($result, $this->equalTo($expected), 'Line: ' . __LINE__ . '.');
 }
开发者ID:akirsoft,项目名称:joomla-cms,代码行数:16,代码来源:JDatabaseQueryTest.php

示例2: processFilters

 /**
  * Process the query filters.
  *
  * @param JDatabaseQuery $query   The query object.
  * @param array          $filters The filters values.
  *
  * @return  JDatabaseQuery The db query object.
  */
 protected function processFilters(\JDatabaseQuery $query, $filters = array())
 {
     $user = $this->container->get('user');
     $db = $this->container->get('db');
     $date = $this->container->get('date');
     // If no state filter, set published >= 0
     if (!isset($filters['user.state']) && property_exists($this->getTable(), 'state')) {
         $query->where($query->quoteName('user.state') . ' >= 0');
     }
     // Category
     // =====================================================================================
     $category = $this->getCategory();
     if ($category->id != 1 && in_array('category.lft', $this->filterFields) && in_array('category.rgt', $this->filterFields)) {
         $query->where($query->format('(%n >= %a AND %n <= %a)', 'category.lft', $category->lft, 'category.rgt', $category->rgt));
     }
     // Max Level
     // =====================================================================================
     $maxLevel = $this->state->get('filter.max_category_levels', -1);
     if ($maxLevel > 0) {
         $query->where($query->quoteName('category.level') . " <= " . $maxLevel);
     }
     // Edit Access
     // =====================================================================================
     if ($this->state->get('filter.unpublished')) {
         $query->where('user.state >= 0');
     } else {
         $query->where('user.state > 0');
         $nullDate = $query->Quote($db->getNullDate());
         $nowDate = $query->Quote($date->toSQL(true));
         if (in_array('user.publish_up', $this->filterFields) && in_array('user.publish_down', $this->filterFields)) {
             $query->where('(user.publish_up = ' . $nullDate . ' OR user.publish_up <= ' . $nowDate . ')');
             $query->where('(user.publish_down = ' . $nullDate . ' OR user.publish_down >= ' . $nowDate . ')');
         }
     }
     // View Level
     // =====================================================================================
     if ($access = $this->state->get('filter.access') && in_array('user.access', $this->filterFields)) {
         $query->where(new InCompare('user.access', $user->getAuthorisedViewLevels()));
     }
     // Language
     // =====================================================================================
     if ($this->state->get('filter.language') && in_array('a.language', $this->filterFields)) {
         $lang_code = $db->quote(JFactory::getLanguage()->getTag());
         $query->where("a.language IN ('{$lang_code}', '*')");
     }
     return parent::processFilters($query, $filters);
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:55,代码来源:users.php

示例3: buildWheres

 /**
  * Build conditions into query object.
  *
  * @param   Query  $query       The query object to add where conditions.
  * @param   array  $conditions  The where conditions array to add to query object.
  *
  * @return  Query  Return the query object.
  */
 public static function buildWheres(Query $query, array $conditions)
 {
     foreach ($conditions as $key => $value) {
         // NULL
         if ($value === null) {
             $query->where($query->format('%n = NULL', $key));
         } elseif ($value instanceof Compare) {
             $query->where((string) static::buildCompare($key, $value, $query));
         } elseif (is_numeric($key)) {
             $query->where($value);
         } elseif (is_array($value) || is_object($value)) {
             $value = array_map(array($query, 'quote'), (array) $value);
             $query->where($query->quoteName($key) . new QueryElement('IN ()', $value, ','));
         } else {
             $query->where($query->format('%n = %q', $key, $value));
         }
     }
     return $query;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:27,代码来源:QueryHelper.php

示例4: postGetQuery

 /**
  * The post getQuery object.
  *
  * @param JDatabaseQuery $query The db query object.
  *
  * @return  void
  */
 protected function postGetQuery(\JDatabaseQuery $query)
 {
     $keys = $this->state->get('profileKeys');
     // Build SQL Pivot
     // ========================================================================
     foreach ($keys as $key) {
         if ($key) {
             /*
              * Use MySQL Pivot query:
              * MAX(IF(profile.key = 'foo', profile.value, NULL)) AS foo
              */
             $query->select($query->format("MAX(IF(profile.key = %q, profile.value, NULL)) AS %e", $key, $key));
         }
     }
     $query->group('user.id');
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:23,代码来源:users.php

示例5: postGetQuery

 /**
  * The post getQuery object.
  *
  * @param JDatabaseQuery $query The db query object.
  *
  * @return  void
  */
 protected function postGetQuery(\JDatabaseQuery $query)
 {
     $query->where($query->format('%n = %q', 'type', 'plugin'));
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:11,代码来源:plugins.php


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