使用Doctrine和MySQL的Symfony
对于使用关系的schema.yml,您是否必须使用InnoDB?这是我的模式:使用Doctrine和MySQL的Symfony
BuybackStatus:
connection: doctrine
tableName: buyback_statuses
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
BuybackStatus:
local: id
foreign: status_id
type: one
Country:
connection: doctrine
tableName: countries
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
code:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
StateCountry:
local: id
foreign: state_id
type: one
UserCountry:
local: id
foreign: state_id
type: one
Manufacture:
connection: doctrine
tableName: manufactures
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
PhoneModelManufacture:
local: id
foreign: manufacture_id
type: one
PhoneModel:
connection: doctrine
tableName: phone_models
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
manufacture_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
buyback_price:
type: 'decimal(6, 2)'
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
PhoneModelManufacture:
onDelete: CASCADE
local: manufacture_id
foreign: id
BuybackModel:
local: id
foreign: model_id
type: one
Quality:
connection: doctrine
tableName: qualities
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
percent:
type: 'decimal(6, 2)'
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
BuybackQuality:
local: id
foreign: quality_id
type: one
State:
connection: doctrine
tableName: states
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
label:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
code:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
country_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
StateCountry:
onDelete: CASCADE
local: country_id
foreign: id
foreignAlias: StateCountries
UserState:
local: id
foreign: state_id
type: one
User:
connection: doctrine
tableName: users
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
fname:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
lname:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
phone:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
email:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
password:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
street:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
city:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
state_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
country_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
UserState:
onDelete: CASCADE
local: state_id
foreign: id
type: one
UserCountry:
onDelete: CASCADE
local: country_id
foreign: id
type: one
BuybackUser:
local: id
foreign: user_id
type: many
BuybackPhone:
connection: doctrine
tableName: buyback_phones
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
user_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
model_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
quality_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
buyback_status_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
amount_quoted:
type: 'decimal(6, 2)'
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
amount_paid:
type: 'decimal(6, 2)'
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
makes_calls:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
water_damage:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
has_charger:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
has_battery:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
BuybackUser:
onDelete: CASCADE
local: user_id
foreign: id
type: one
BuybackModel:
onDelete: CASCADE
local: model_id
foreign: id
type: one
BuybackQuality:
onDelete: CASCADE
local: quality_id
foreign: id
type: one
BuybackStatus:
onDelete: CASCADE
local: buyback_status_id
foreign: id
type: one
但是数据库是MyISAM。所以,当我运行:php symfony doctrine:build --model
我得到这些一堆:
Notice: Undefined index: class in /home/kacie/cellphone/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Builder.php on line 672
我是全新的,以Symfony的,所以我可以搞砸了的模式,请检查。
下面是它实际负载:
>> tokens /home/kacie/cellphone/lib/model/doctrine/PhoneModel.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/PhoneModelTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackStatus.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackPhoneTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/Manufacture.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/CountryTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/Country.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/ManufactureTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/UserTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/Quality.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackPhone.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackStatusTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/User.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/State.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/StateTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/QualityTable.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseState.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackStatus.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseUser.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackPhone.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseManufacture.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BasePhoneModel.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseQuality.class.php
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseCountry.class.php
>> autoload Resetting application autoloaders
>> file- /home/kacie/cellphone/cache/frontend/prod/config/config_autoload.yml.php
不过在此之前有一堆未定义指数告示的,我不想再往前走,我现在已经报废申请几次并尝试了很多东西,但我认为这个模式会起作用。在这里控制数据库创建的人有他的心在MyISAM,所以我不想让他改变它,如果有什么我可以做的解决它。可悲的是,我有创建数据库的脚本,但是当我从已经存在的结构中生成模式时,它将遗漏关系,并且由于我对symfony不熟悉,因此我希望尽可能使所有内容自动化。
我认为问题在于您使用两次相同的关系名称。 我发现至少有三个:“UserState”,“BuyBackModel”,“BuyBackQuality”,在您的schema.yml中使用两次。
尝试确保所有关系都是唯一的,然后再次尝试生成模型。
编辑
另一件事你应该尝试,是增加类名到你的关系。
<...>
Relations:
class: foo
<...>
我遇到了这个问题。这些想法都没有奏效,因为我认为这是另一个问题。
./symfony学说:内置模式
不断把旧的关系不再存在,到我的架构。所以无论是Symfony有一些模糊的地方,它缓存了旧的关系,或者MySQL正在报告不再存在的关系。
我认为Symfony正在从其他来源,如窗体或过滤器拉关系。我将尝试清除表单和过滤器的基本目录。
嗯。找到了。在我的GUI中,外键在MySQL中没有被删除,在WorkBench中。你也必须删除索引。
最佳解决方案。备份您的数据库结构和内容。如果你的MySQL的GUI工具有问题,重新创建数据库。
我继续做了一个InnoDB,并根据它创建了一个模式。你应该使用类名作为关系名。像这样: 'States: ... 关系: 国家 地方:COUNTRY_ID 国外:ID 类型:一个 用户: 地方:ID 国外:STATE_ID 类型:many' – KacieHouser 2010-08-18 18:17:52
高兴你想通弄明白了。 – jgallant 2010-08-19 10:58:27