Friday, October 29, 2010

SQLSTATE[HY000]: General error: 1005 Can't create table

Let's see a very simple CORRECT relation and reasons why it can throw SQLSTATE[HY000]: General error...

      foreignAlias: Phonenumbers
      local: user_id
      foreign: id
      type: one
      foreignType: many

  1. Did you forget to define the user_id field in the Phonenumber table?
  2. Did you check the type of the user_id field and the Phonenumber table's id field? They must be exactly the same integer. If one of them is int(4) and the other is int(8), the building will fail.

1 comment: