Pour schema.yml de travailler avec des relations, avez-vous InnoDB? Voici mon schéma:Symfony en utilisant Doctrine et MySQL
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
Mais la base de données est MyISAM. Alors, quand je lance: php symfony doctrine:build --model
je reçois un tas de ces derniers:
Notice: Undefined index: class in /home/kacie/cellphone/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Builder.php on line 672
Je suis tout nouveau à Symfony, pour que je puisse être en plissant le schéma, s'il vous plaît vérifier.
Voici ce qu'il fait la charge:
>> 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
Mais avant cela, il y a un tas d'avis Undefined index, je ne veux pas aller plus loin, j'ai mis au rebut l'application quelques fois et essayé beaucoup de choses, mais je pensais que ce schéma fonctionnerait. Le gars qui contrôle la création de la base de données ici a son coeur sur MyISAM, donc je ne veux pas essayer de le faire changer s'il y a quelque chose que je peux faire pour le contourner. La chose triste est, j'ai des manuscrits pour créer la base de données, mais quand je crée le schéma hors de ma structure déjà en place il laisse les relations, et puisque je suis nouveau à symfony, je veux que tout soit aussi automatisé que possible.
Je suis allé de l'avant et a fait un InnoDB et fait un schéma basé sur elle. Vous êtes censé utiliser le nom de la classe comme nom de la relation. Comme ceci: 'Etats: ... relations: Pays: locales: country_id étranger: id Type : un utilisateurs: locaux: id étrangers: Type state_id : many' – KacieHouser
Heureux vous l'avez compris. – jgallant