Yii Framework Forum: Chapter 6 FK_user_project - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 6 FK_user_project

#1 User is offline   corbeeresearch 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 21-August 10

Posted 18 January 2011 - 11:35 PM

Hi,

For some reasons, this part of the sql command won't work

ALTER TABLE 'tbl_project_user_assignment' ADD CONSTRAINT 'FK_user_
project' FOREIGN KEY ('user_id') REFERENCES 'tbl_user' ('id') ON
DELETE CASCADE ON UPDATE RESTRICT

0

#2 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 19 January 2011 - 12:54 AM

If you are using the MySQL command line client when entering such statements, you may need to alter all of the single quote characters from

'


to

`


Otherwise, are you using MySQL? What version?
0

#3 User is offline   corbeeresearch 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 21-August 10

Posted 19 January 2011 - 01:47 AM

I finally solved it.

Strange, I emptied the whole database and pasted everything, but that same FK_user_project won't work.

I decided to delete the whole database instead of just emptying it and it worked.

I don't know why. It must have turned corrupted.

Thanks for your reply.
0

#4 User is offline   Darryl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 23-January 11

Posted 23 January 2011 - 09:58 AM

I am having the same problem. I am using phpmyadmin. First I had to remove all the single quotes. It finally created the tables, but now I am stuck at altering the tables. I have deleted the whole database as corbeeresearch suggested, to no avail.

This is the error message I am receiving:

SQL query:

ALTER TABLE tbl_issue ADD CONSTRAINT FK_issue_project FOREIGN KEY(project_id) REFERENCES tbl_project(id) ON DELETE CASCADE ON UPDATE RESTRICT ;

MySQL said:

#1005 - Can't create table 'test.#sql-10e0_c4' (errno: 150)

Any suggestions,

Thanks
0

#5 User is offline   Darryl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 23-January 11

Posted 23 January 2011 - 11:49 AM

Ok. I got it. For some reason my project table was not set as InnoDB. Once I set that and removed all the single quotes, it worked in phpmysql and trough netbeans IDE.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users