Answer the question
In order to leave comments, you need to log in
How to make join yii2?
There are 2 related tables. In one, which is called - Applications - there is a field f1740 - it shows the manager's id and refers to another table - Users, where in the field f483 - the manager's name.
Here is a table call with managers:
public function actionManagersSelect()
{
$request = Yii::$app->request;
if ($request->isPost) {
$data = Managers::find()->select(['f483', 'f5021'])->where(['id' => [5, 7, 9, 33, 10, 30, 35, 16]])/*->indexBy('f483')*/->all();
Yii::$app->response->format = Response::FORMAT_JSON;
return $data;
}else throw new \yii\web\BadRequestHttpException;
}
public function actionZayavka()
{
$request = Yii::$app->request;
if ($request->isPost) {
$data = Zayavka::find()->select(['f1740', ])->orderBy('id desc')->limit(5)->all();
Yii::$app->response->format = Response::FORMAT_JSON;
return $data;
}else throw new \yii\web\BadRequestHttpException;
}
Answer the question
In order to leave comments, you need to log in
how to assign the value f483 to the f1740 field so that the name of the manager is displayed instead of id,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question