SELECT
( SELECT CONCAT( MAX( fd_config_item.date_created ), MAX( fd_config_item.date_edited ) ) FROM fd_config_item ) fd_config_item,
( SELECT CONCAT( MAX( fd_config_item_group.date_created ), MAX( fd_config_item_group.date_edited ) ) FROM fd_config_item_group ) fd_config_item_group
/** @var LanguageManager $languageManager */
$languageManager = Yii::$app->languageManager;
class Yii extends \yii\BaseYii
{
/**
* @var BaseApplication|WebApplication|ConsoleApplication
*/
public static $app;
}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
abstract class BaseApplication extends \yii\base\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class WebApplication extends \yii\web\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class ConsoleApplication extends \yii\console\Application {}
$form = ActiveForm::begin([
'fieldConfig' => [
'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
],
]);
$city = City::findOne( ... );
$city->region->country
$country = Country::findOne( ... );
foreach( $country->regions as $region ) {
foreach ( $region->cities as $city ) {
echo $city->name
}
}
Возвращает:
Undefined property: app\models\Foo::$option
[ [ 'score' ], 'compare', 'compareValue' => 1, 'operator' => '>=' ],
[ [ 'score' ], 'compare', 'compareValue' => 100, 'operator' => '<=' ],
# или
[ [ 'score' ], 'in', 'range' => [ 1, ..., 100 ] ],
# или
[ [ 'score' ], function ( $attribute, $params ) {
if ( !( $this->$attribute >= 1 && $this->$attribute <= 100 ) ) {
# Ошибка!
}
} ],
Самое сложное понять как работают модели для сохранения связанных данных в Yii2.
$article = new Article( [ ... ] );
$article->save();
$author = new Author( [ ... ] );
$author->save();
$article2Author = new ArticleAuthor( [
'article_id' => $article->id,
'author_id' => $author->id,
] );
$article2Author->save();