Вход Регистрация
Файл: concrete5.7.5.6/concrete/src/Search/ItemList/Database/ItemList.php
Строк: 79
<?php
namespace ConcreteCoreSearchItemListDatabase;
use 
ConcreteCoreSearchStickyRequest;
use 
Database;
use 
ConcreteCoreSearchItemListItemList as AbstractItemList;
use 
DoctrineDBALLoggingEchoSQLLogger;

abstract class 
ItemList extends AbstractItemList
{

    
/** @var DoctrineDBALQueryQueryBuilder */
    
protected $query;

    
/** @var  ConcreteCoreSearchStickyRequest | null */
    
protected $searchRequest;

    abstract public function 
createQuery();

    
/**
     * @param DoctrineDBALQueryQueryBuilder $query
     * @return DoctrineDBALQueryQueryBuilder
     */
    
public function finalizeQuery(DoctrineDBALQueryQueryBuilder $query)
    {
        return 
$query;
    }

    public function 
__construct(StickyRequest $req null)
    {
        
$this->query Database::get()->createQueryBuilder();
        
$this->searchRequest $req;
        
$this->createQuery();
    }

    public function 
getQueryObject()
    {
        return 
$this->query;
    }

    public function 
deliverQueryObject()
    {
        
// setup the default sorting based on the request.
        
$this->setupAutomaticSorting($this->searchRequest);
        
$query = clone $this->query;
        
$query $this->finalizeQuery($query);
        return 
$query;
    }

    public function 
executeGetResults()
    {
        return 
$this->deliverQueryObject()->execute()->fetchAll();
    }

    public function 
debugStart()
    {
        if (
$this->isDebugged()) {
            
Database::get()->getConfiguration()->setSQLLogger(new EchoSQLLogger());
        }
    }

    public function 
debugStop()
    {
        if (
$this->isDebugged()) {
            
Database::get()->getConfiguration()->setSQLLogger(null);
        }
    }

    protected function 
executeSortBy($column$direction 'asc')
    {
        if (
in_array(strtolower($direction), array('asc','desc'))) {
            
$this->query->orderBy($column$direction);
        } else {
            throw new 
Exception(t('Invalid SQL in order by'));
        }
    }

    protected function 
executeSanitizedSortBy($column$direction 'asc')
    {
        if (
preg_match('/[^0-9a-zA-Z$._x{0080}-x{ffff}]+/u'$column) === 0) {
            
$this->executeSortBy($column$direction);
        } else {
            throw new 
Exception(t('Invalid SQL in order by'));
        }
    }

    
/**
     * @deprecated
     */
    
public function filter($field$value$comparison '=')
    {
        if (
$field == false) {
            
$this->query->andWhere($value); // ugh
        
} else {
            
$this->query->andWhere(implode(' ', array(
               
$field$comparison$this->query->createNamedParameter($value)
            )));
        }
    }

}
Онлайн: 1
Реклама