Hi everyone,
I am trying to execute a JOIN query from the function actionCreate in the CampaniaController like that …
$dataProvider = new ActiveDataProvider([
'query' => Empresa::find()
->joinWith('TblEmpUserFechas'),
]);
I have tested without a JOIN and everything works perfectly. But When I have to join 2 relationed tables in my database with a JOIN in yii2, it doesn’t work anymore. This error appears …
exception 'yii\base\ErrorException' with message 'Class 'frontend\models\TblEmpUserFecha' not found' in C:\..\frontend\models\Empresa.php:65
I am sure that dataModels Empresa and EmpUserFecha are right relationed as you can see below (hasMany) …
- Empresa …
* @property integer $id
* @property TblEmpUserFecha[] $tblEmpUserFechas
*/
class Empresa extends \yii\db\ActiveRecord
{
...
/**
* @return \yii\db\ActiveQuery
*/
public function getTblEmpUserFechas()
{
return $this->hasMany(TblEmpUserFecha::className(), ['id_empresa' => 'id']);
}
...
}
- EmpUserFecha …
* @property TblEmpresa $idEmpresa
class EmpUserFecha extends \yii\db\ActiveRecord
{
...
/**
* @return \yii\db\ActiveQuery
*/
public function getIdEmpresa()
{
return $this->hasOne(TblEmpresa::className(), ['id' => 'id_empresa']);
}
...
}
More info: Models in the database are called as: tbl_empresa and tbl_emp_user_fecha. This lasta one has 3 foreign keys, and one of them to tbl_empresa
Some ideas? Thanks a lot!