mootensai / yii2-enhanced-gii

Enhanced Yii2 Gii (generator) that generates related Models & CRUD
MIT License
203 stars 98 forks source link

"Call to a member function getColumnNames() on null" #160

Closed drew1two closed 3 years ago

drew1two commented 3 years ago

Error occurs in _datarefone.php line 15:- $pk = empty($tableSchema->primaryKey) ? $tableSchema->getColumnNames()[0] : $tableSchema->primaryKey[0];

This is because there is no tableSchema being generated. Need to change line 14 from :- $tableSchema = $generator->getDbConnection()->getTableSchema($relations[$generator::REL_CLASS]); to:- $tableSchema = $generator->getDbConnection()->getTableSchema($relations[$generator::REL_TABLE]); getTableSchema takes the tableName, not the className.

And all is good in the world again :)

mootensai commented 3 years ago

Hi! Could you make a PR for this? I'm back in WebDev now. I will have time to maintain this repo again.