buildQuery() для модели joomla

function _buildQuery()
{
//Переменные запроса
$where = array();
$left_join = array();
$limit=null;
$orderby = null;
$select = array();


$select[] = "a.*";

if (!empty($this->_filter_text))
{
$searchEscaped = $this->_db->Quote( '%'.$this->_db->getEscaped( $this->_filter_text, true ).'%', false );
$where[] = 'a.title LIKE '.$searchEscaped;
}


//Преобразовать в строки
$where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' );
if ($this->getState('limit')>0) $limit=' LIMIT '.$this->getState('limitstart').','. $this->getState('limit').'';
$orderby = ' ORDER BY '. $this->_filter_order .' '. $this->_filter_order_Dir;      

$left_join = ( count( $left_join ) ?  ' '.implode( ' ', $left_join ).' '  : '' );


$query = ' SELECT SQL_CALC_FOUND_ROWS '.implode(',',$select)

. ' FROM #__test AS a'
.$left_join
.$where
.$orderby
.$limit;



return $query;
}

Добавить комментарий


Покупка готового скрипта

joomla 3