gpt4 book ai didi

mysql - Symfony 使用 Doctrine 和 MySQL

转载 作者:行者123 更新时间:2023-11-29 09:17:51 24 4
gpt4 key购买 nike

要使 schema.yml 能够处理关系,是否必须使用 InnoDB?这是我的架构:

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 symfonydoctrine: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

但在此之前有一堆 undefined index 通知,我不想再进一步了,我已经废弃了几次应用程序并尝试了很多东西,但我认为这个模式可以工作。控制这里数据库创建的人一心扑在 MyISAM 上,所以如果我能做点什么来解决这个问题,我不想尝试让他改变它。可悲的是,我有脚本来创建数据库,但是当我根据已有的结构生成模式时,它忽略了关系,而且由于我是 symfony 的新手,我希望一切都尽可能自动化。

最佳答案

我认为问题在于您两次使用相同的关系名称。我发现至少三个:“UserState”、“BuyBackModel”、“BuyBackQuality”,它们在 schema.yml 中使用了两次

尝试确保所有关系都是唯一的,然后尝试再次生成模型。

编辑

您应该尝试的另一件事是向您的关系添加类名称。

<...>
Relations:
class: foo
<...>

关于mysql - Symfony 使用 Doctrine 和 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3513155/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com