Hi,
Is there a list of prohibited database table names in Yii/Yii2?
I was creating an application in Yii2 with 3 tables, product, attribute, and product_attribute (where product_attribute was a junction table).
Gii, had no problems creating a model for all 3 tables and corresponding CRUD for product and attribute.
But the resultant code had a bug in it for the model ProductAttribute. Specifically for
/**
* @return \yii\db\ActiveQuery
*/
public function getAttribute()
Cannot remember the exact error, but PHPStorm picked it up as well and said something like:
Declaration must be compatible with ActiveRecordInterface->getAttribute(name : string)
/**
* @return \yii\db\ActiveQuery
*/
public function getAttribute()
{
return $this->hasOne(Attribute::className(), ['id' => 'attribute_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProduct()
{
return $this->hasOne(Product::className(), ['id' => 'product_id']);
}
I got around it by calling my table in the database atribute (only 1 t). And everything seemed to work fine. Is attribute a known no-no for db table names in Yii?
Cheers!