我在symfony docs that创建了你可以从现有数据库中生成实体所以有没有办法从现有数据库更新实体我用mysql添加它? 例如 我在我的FOSUSERBUNDLE数据库中添加了一个名为“batman”的新列
在mysql上使用这个推荐
#ignored: condition 0
if ($http_host ~* "^www\."){
set $rule_0 1;
break;
}
if ($rule_0 = "1"){
rewrite ^/ https://example.com$uri permanent;
}
rewrite ^/directory/([A-Za-z-]+)/?$ https://example.com/directory/$1.php last;
rewrite ^/rss/medicinecategory.php$ https://example.com/directory/medical-specialties permanent;
rewrite ^/rss/medicalconditions.php$ https://example.com/directory/medical-conditions permanent;
rewrite ^/rss/cancers.php$ https://example.com/directory/cancers permanent;
rewrite ^/rss/infectiousdiseases.php$ https://example.com/directory/infectious-diseases permanent;
rewrite ^/rss/surgical_procedures.php$ https://example.com/directory/medical-procedures permanent;
rewrite ^/rss/therapies.php$ https://example.com/directory/therapies permanent;
rewrite ^/rss/vaccines.php$ https://example.com/directory/vaccines permanent;
rewrite ^/rss/drugs.php$ https://example.com/directory/drugs permanent;
rewrite ^/rss/health_management.php$ https://example.com/directory/health-management permanent;
rewrite ^/rss/medical_education.php$ https://example.com/directory/medical-training permanent;
if ($args ~ "podcasts|blogs|news"){
set $rule_12 1$rule_12;
}
if ($rule_12 = "1"){
rewrite ^/rss/index.php/Consumer-Health-Advice/91/$ https://example.com/rss/index.php/Consumer-Health-News/26/ permanent;
}
rewrite ^/rss/index.php/Consumer-Health-Advice/91/$ https://example.com/rss/index.php/Consumer-Health-News/26/$1? permanent;
如何使用上面的文档指南更新我生成的实体?
答案 0 :(得分:0)
如果需要将数据库架构更新为Entity,可以使用两个命令:
(1)从数据库创建实体映射:
bin/console doctrine:mapping:import BundleName --filter=EntityName
(2)更新您的实体以匹配此映射:
bin/console doctrine:generate:entities BundleName:EntityName
示例,我在数据库中有一个User表,已经改变了这个表的结构。现在,我想在AppBundle中将这些更改更新到我的用户实体。我需要运行以下命令:
bin/console doctrine:mapping:import AppBundle --filter=User
bin/console doctrine:generate:entities AppBundle:User
我希望这可以帮到你!
答案 1 :(得分:0)
对于像我一样在忘记后仍然找不到该命令的任何人,这里是:
当我从已经存在的sql数据库更新实体时,我只是使用以下命令:
php bin/console doctrine:mapping:import --force AppBundle annotation --filter="Entity name".
我正在使用symfony 3.4,但我认为这也适用于更高版本。