Не понимаю почему тут array(). По идее тут можно вставить обычный SQL запрос.
<?php
$this->widget('application.modules.user.widgets.UsersList', array(
'condition' => array(
'limit' => 2,
'together' => true,
'group' => 't.id',
'condition' => 'categories.id="159"'
),
'type' =>'contest',
'view' => 'contest'
)); ?>
<?php
$this->widget('application.modules.user.widgets.UsersList', array(
'condition' => array(
'limit' => 12,
'together' => true,
'group' => 't.id',
'cid' => 159
),
'type' =>'contest',
'view' => 'contest'
));
?>
<?php
class UsersList extends yupe\widgets\YWidget
{
public $view = 'main';
public $condition = array();
public $type = "professional";
public function run()
{
$id = $this->getId();
if ($this->type == "professional") {
$users = User::model()->professionals();
}
elseif ($this->type == "company") {
$users = User::model()->companies();
}
elseif ($this->type == "contest") {
$users = User::model()->contests();
}
else {
$users = User::model()->organizations();
}
$models = $users->with('categories', 'tags')->findAll($this->condition);
$this->render($this->view, array('models' => $models, 'type' => $this->type, 'id' => $id));
}
}
public function run()
{
$model = User::model();
$criteria = new CDbCriteria(array(
'select' => 't.*',
'condition' => 't.status = :status AND t.comments_count > 0',
'params' => array(':status' => User::STATUS_ACTIVE),
'limit' => $this->limit,
'order' => 't.comments_count DESC',
));
$users = $model->findAll($criteria);
if($users)
$this->render($this->view, array('models' => $users));
}
$models = $users->with('categories', 'tags')->findAll($this->condition);
<?php/**
* Входной скрипт index:
*
* @category YupeScript
* @package YupeCMS
* @author Yupe Team <team@yupe.ru>
* @license https://github.com/yupe/yupe/blob/master/LICENSE BSD
* @link http://yupe.ru
**/
// подробнее про index.php http://www.yiiframework.ru/doc/guide/ru/basics.entry
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
define('YII_DEBUG', false);
$development = isset($_SERVER['SERVER_ADDR'])
? strpos($_SERVER['SERVER_ADDR'], '127') === 0
: $_SERVER['SERVER_NAME'] == 'localhost';
// Выбираем конфигурацию development-main.php, если сайт работает на localhost
if ($development || defined('APPLICATION_ENV') || getenv('APPLICATION_ENV') !== false) {
// Комментируем перед выпуском в продакшен:
// в режиме разработки необходимо демонстрировать все ошибки
// независимо от среды
ini_set('display_errors', 'On');
define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
// В режиме разработки - отключаем кеширование настроек:
defined('CACHE_SETTINGS') or define('CACHE_SETTINGS', false);
// путь к фреймворку Yii
$yii = dirname(__FILE__) . '/../vendor/yiisoft/yii/framework/yii.php';
} else { //production считается во всех случаях, когда не выполнены условия
// путь к фреймворку Yii, при необходимости заменить на yii.php
$yii = dirname(__FILE__) . '/../vendor/yiisoft/yii/framework/yiilite.php';
// путь к основному конфигурационному файлу Yii
}
require $yii;
$base = require dirname(__FILE__) . '/../protected/config/main.php';
$userspace = dirname(__FILE__) . '/../protected/config/userspace.php';
$userspace = file_exists($userspace) ? (require $userspace) : array();
$confManager = new yupe\components\ConfigManager();
$config = $confManager->merge($base, $userspace);
require dirname(__FILE__).'/../vendor/autoload.php';
ini_set('display_errors', 1);
error_reporting(E_ERROR);
Yii::createWebApplication($config)->run();