views:

89

answers:

1

For schema.yml to work with relations, do you have to InnoDB? Here is my schema:

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

But the database is MyISAM. So when I run: php symfony doctrine:build --model I get a bunch of these:

Notice: Undefined index:  class in /home/kacie/cellphone/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Builder.php on line 672

I am brand new to Symfony, so I could be screwing up the schema, please check.

Here is what it does actually load:

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

But before this there are a bunch of Undefined Index Notices, I don't want to go any further, I have scrapped the application a few times now and tried a lot of things, but I thought this schema would work. The guy who controls the database creation around here has his heart set on MyISAM, so I don't want to try and make him change it if there is something I can do to work around it. The sad thing is, I have scripts to create the database, but when I generate the schema off of my already in place structure it leaves out the relations, and since I am new to symfony, I want everything as automated as possible.

+1  A: 

I think the problem is that you are using the same Relations name twice. I found at least three: "UserState", "BuyBackModel", "BuyBackQuality" which are used twice in your schema.yml

Try to make sure all your relations are unique, and try generating the model again.

EDIT

Another thing you should try, is adding class names to your Relations.

<...>
Relations:
   class: foo
<...>
Jon
I went ahead and did an InnoDB and made a schema based off it. You are supposed to use the class name as the relation name. Like so:`States:... relations: Countries: local: country_id foreign: id type: one Users: local: id foreign: state_id type: many`
KacieHouser
Glad you got it figured out.
Jon