Answer the question
In order to leave comments, you need to log in
How to write SQL query for yii2 framework?
Actually the code itself in PHP, how to make it understandable by the framework.
$sql = "select famelia, imya, otchestvo, data, model from get_cartridge, cartridge, otvetstveniy where otvetstveniy.id = get_cartridge.id_otvet and cartridge.id = get_cartridge.id_get_cartridge";
Попытка сделать экшн и вывод на страницу
public function actionList()
{
$query = new Query;
$query->select(['famelia','imya','otchestvo','data','model'])->from('`get_cartridge`','`cartridge`','`otvetstveniy`',)->where('`otvetstveniy`.`id` = `get_cartridge`.`id_otvet`');
$command = $query->createCommand();
$resp = $command->queryAll();
return $this->render('list', [
'resp' => $resp
]);
}
}
Answer the question
In order to leave comments, you need to log in
Cartridge::find()->joinWith('GetCartridge')->joinWith('Otvetstveniy')->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question