Did you compile it with --fast?
symfony
Symfony Doctrine Foreign Key Error
SQLSTATE[HY000]: General error: 1005 Can't create table X (errno: 150). Failing Query: ALTER TABLE tablename ADD FOREIGN KEY (key_id) REFERENCES table(id)
Ever seen an error message like that before? Many of us have and its a big ole pain in the butt, but never fear, because the fix is simple.
There is an issue with your ID columns. Normally this has to do with the foreign key and primary keys having different length constraints. Your fix:
Make sure that the length constraints match. If you aren't specifying a length, you can simply remove the ID field from your schema.yml, and let Doctrine create it for you, or if you want to be explicit, you can set a length and make sure it is matched in the related foreign key field.
Note: If you are working with sfDoctrineGuard, you must make sure that you define the related field as integer(4)
Examples:
Custom Classes:
Without defining length:
School:
columns:
name: string(255)
Student:
columns:
name: string(255)
grade: string(255)
age: integer(4)
school_id: integer
relations:
School:
local: school_id
foreign: id
foreignAlias: Students
With Defined Length:
School:
columns:
id: integer(4)
name: string(255)
Student:
columns:
name: string(255)
grade: string(255)
age: integer(4)
school_id: integer(4)
relations:
School:
local: school_id
foreign: id
foreignAlias: Students
sfGuard Related Model:
sfGuardUserProfile:
columns:
user_id: integer(4)
email: string(255)
age: integer(4)
Symfony and svn:externals... super-slick the easy way
(If you already know about Symfony and just want to use svn:externals to install it, you might want to skip here)
We've begun using the Symfony MVC framework for some small projects and really getting into it. If you're not familiar with MVC frameworks, then...well, you probably are more familiar than you know: the MVC patternis the design pattern at the heart of well-known development frameworks like Rails and Django. PHP has its own varieties of MVC frameworks, and Symfony ranks along with other popular options such as CakePHP and Code Igniter.
Like most MVC frameworks, a large part of what makes Symfony such a powerful tool is it's meticulously organized codebase. Placement of each piece of the stack is exquisitely thought-out, providing the foundation for an extensive plugin-architecture capable of interfacing with and incorporating numerous third-party libraries and tools. Like any intricate protocol, however, the organization of Symfony's code can be somewhat daunting and labyrinthine, contributing to its fairly steep learning curve.
Luckily there are some great tutorials and references out there, including the freely available version of the commercially published Symfony Book, the Getting Started Guide and a bunch more.







