$query = News::find();
$countQuery = $query->count();
$data = Yii::$app->cache->getOrSet('newsCacheKey', function () use ($query) {
return $query->all();
}, $this->cacheDuration, new TagDependency([
'tags' => [
News::className() . $countQuery
]
]));
$yearOfBirth = 18;
$date1 = date((date('Y') - $yearOfBirth - 1) . '-m-d');
$date2 = date((date('Y') - $yearOfBirth) . '-m-d');
$query=Napravlenie::find()->joinWith(['pacients' => function ($q) use ( $date1, $date2) {
$q->where("pacients.dr BETWEEN :d1 AND :d2",["d1"=>$date1,"d2"=>$date2]);
}]);
class MyClass2{
public $var = 123;
}
class MyClass{
public $var;
function __construct(){
$this->var = new MyClass2();
}
}
function myFunc(){
return new MyClass();
}
echo myFunc()->var->var;