Answer the question
In order to leave comments, you need to log in
Yii2 how to insert parameters into a function?
Still found how to filter. Here is the code
$query=Napravlenie::find()->joinWith(['pacients' => function ($q) {
$q->where('pacients.dr="1990-02-25"');
}]);
$yearOfBirth = 18;
$date1 = date((date('Y') - $yearOfBirth - 1) . '-m-d');
$date2 = date((date('Y') - $yearOfBirth) . '-m-d');
$query=Napravlenie::find()->joinWith(['pacients' => function ($q, $date1, $date2) {
$q->where("pacients.dr BETWEEN $date1 AND $date2");
}]);
Answer the question
In order to leave comments, you need to log in
$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]);
}]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question