class Order extends ActiveRecord
{
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios[self::SCENARIO_DEFAULT] = [/** Все поля без поля status */];
$scenarios['editWithStatus'] = [/** Все поля */];
return $scenarios;
}
}
public static function getList()
{
return static::find()
->select(['name', 'id'])
->indexBy('id')
->asArray()
->column();
}
// @see \yii\db\pgsql\QueryBuilder::resetSequence()
$sql_resetSequence = Yii::$app->db->queryBuilder->resetSequence($table, $value);
Yii::$app->db->createCommand($sql_resetSequence)->execute();
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'name',
'filterInputOptions' => [
'placeholder' => 'название книги',
'class' => 'form-control',
'id' => null,
]
]
]
]);
$db = Post::getDb();
$db->transaction(function($db) {
$db->createCommand($sql1)->execute();
$db->createCommand($sql2)->execute();
// ... executing other SQL statements ...
});
$dataProvider = new ActiveDataProvider([
'query' => Images::find()
->orderBy(['sort_order' => SORT_ASC]),
'pagination' => false,
'sort' => false,
]);
use himiklab\sortablegrid\SortableGridView as GridView;
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
/* твои колонки */
],
]);
$users = User::find()
->indexBy('id')
->all();
$friends = Friend::find()
->indexBy('id')
->all();
$result = array_intersect_key($users, $friends);
namespace frontend\assets;
class AppAsset extends AssetBundle
{
public $sourcePath = '@frontend/resource';
public $css = [
'css/site.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
}
namespace frontend\widgets\FlexSlider;
class SliderAsset extends AssetBundle
{
public $sourcePath = '@vendor/bower/flexslider';
public $css = [
// 'flexslider.css'
];
public $js = [
'jquery.flexslider.js'
];
public $depends = [
'frontend\assets\AppAsset',
'yii\web\JqueryAsset',
];
}
return [
'timeZone' => 'Europe/Minsk',
'components' => [
'formatter' => [
'dateFormat' => 'd.MM.yyyy',
'timeFormat' => 'H:mm:ss',
'datetimeFormat' => 'd.MM.yyyy H:mm',
],
],
];
Yii::$app->getFormatter()->asDate(time());
Yii::$app->getFormatter()->asDatetime(time())
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'created_at:datetime',
],
]); ?>
class DefaultController extends Controller
{
public function actionIndex()
{
/** ваш код */
$this->renderAjax('index', [
/** params */
])
}
}