-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gii can not generate model from mysql tables #407
Comments
Can you show your table schema including relations as the error is in the section that builds relations. |
Thanks for posting in our issue tracker.
Thanks! This is an automated comment, triggered by adding the label |
It seems any mysql foreign key will be sufficient to get error. CREATE TABLE `a` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `b` (
`id` int(11) NOT NULL,
`a_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `a_id` (`a_id`),
CONSTRAINT `b_ibfk_1` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8" Error on generating models for both tables |
I tested further and model generator fails even without foreign keys. Even with "Generate Relations from Current Schema" disabled. May be PHP 7.3 is the cause? |
Can you downgrade and check it? |
I found mysql scheme pattern that causes error CREATE TABLE `a` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `b` (
`id` int(11) NOT NULL,
`a_id` int(11) NOT NULL,
`some_field` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `a_id` (`a_id`, `some_field`),
CONSTRAINT `a_id` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) When you have a table like 'b' in your db, model generator will fail on every table because it scans all tables relations. |
When I try to use Model Generator
PHP Warning – yii\base\ErrorException
array_flip(): Can only flip STRING and INTEGER values!
mysql 8
php 7.3
Yii 2.0.17
centos 7
The text was updated successfully, but these errors were encountered: