本文整理汇总了PHP中JDatabaseQuery::quoteName方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery::quoteName方法的具体用法?PHP JDatabaseQuery::quoteName怎么用?PHP JDatabaseQuery::quoteName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseQuery
的用法示例。
在下文中一共展示了JDatabaseQuery::quoteName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testQuoteNameException
/**
* Tests the JDatabaseQuery::quoteName method for an expected exception.
*
* @return void
*
* @covers JDatabaseQuery::quoteName
* @expectedException RuntimeException
* @since 11.3
*/
public function testQuoteNameException()
{
// Override the internal database for testing.
$this->_instance->db = new stdClass;
$this->_instance->quoteName('foo');
}
示例2: testQuoteNameException
/**
* Tests the JDatabaseQuery::quoteName method for an expected exception.
*
* @return void
*
* @covers JDatabaseQuery::quoteName
* @expectedException RuntimeException
* @since 11.3
*/
public function testQuoteNameException()
{
// Override the internal database for testing.
TestReflection::setValue($this->_instance, 'db', new stdClass());
$this->_instance->quoteName('foo');
}
示例3: 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);
}
示例4: processOrdering
/**
* Process ordering query.
*
* @param \JDatabaseQuery $query The query object.
* @param string $ordering The ordering string.
* @param string $direction ASC or DESC.
*
* @return void
*/
protected function processOrdering(\JDatabaseQuery $query, $ordering = null, $direction = null)
{
$ordering = $ordering ?: $this->get('list.ordering');
// If no ordering set, ignore this function.
if (!$ordering) {
return;
}
$direction = $direction ?: $this->get('list.direction', 'ASC');
$ordering = explode(',', $ordering);
// Add quote
foreach ($ordering as $key => &$value) {
// Remove extra spaces
$value = preg_replace('/\\s+/', ' ', trim($value));
$value = StringHelper::explode(' ', $value);
if (!$this->filterField($value[0])) {
unset($ordering[$key]);
continue;
}
$value[0] = $this->mapField($value[0]);
// Ignore expression
if (!empty($value[0]) && $value[0][strlen($value[0]) - 1] != ')') {
$value[0] = $query->quoteName($value[0]);
}
$value = implode(' ', $value);
}
$ordering = implode(', ', $ordering);
if (!$ordering) {
return;
}
$query->order($ordering . ' ' . $direction);
}
示例5: 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())
{
// If no state filter, set published >= 0
if (!isset($filters['list.state']) && property_exists($this->getTable(), 'state')) {
$query->where($query->quoteName('list.state') . ' >= 0');
}
return parent::processFilters($query, $filters);
}
示例6: registerQueryTables
/**
* registerQueryTables
*
* @param DatabaseQuery $query
*
* @return DatabaseQuery
*/
public function registerQueryTables(DatabaseQuery $query)
{
foreach ($this->tables as $alias => $table) {
if ($table['join'] == 'FROM') {
$query->from($query->quoteName($table['name']) . ' AS ' . $query->quoteName($alias));
} else {
$query->join($table['join'], $query->quoteName($table['name']) . ' AS ' . $query->quoteName($alias) . ' ' . $table['condition']);
}
}
return $query;
}
示例7: 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())
{
// If no state filter, set published >= 0
if (!isset($filters['icon.published'])) {
$query->where($query->quoteName('icon.published') . ' >= 0');
}
return parent::processFilters($query, $filters);
}