Yii Framework Forum: Crud problem chapter 6 - Yii Framework Forum

Jump to content

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

Crud problem chapter 6 Table 'tbl_issue' has a composite primary key which is not sup

#1 User is offline   K22 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-March 11

Posted 10 March 2011 - 12:20 PM

Hi, ran into a crud problem with the crud generator.
I am trying to create the Issues crud.
This is not working for me.

Table 'tbl_issue' has a composite primary key which is not supported by crud generator.

Is the response I get.
I received no errors in mysql when creating the databases from the code in the book.
Any idea?
0

#2 User is offline   pietrop 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 24-February 11

Posted 15 March 2011 - 04:55 AM

View PostK22, on 10 March 2011 - 12:20 PM, said:

Table 'tbl_issue' has a composite primary key which is not supported by crud generator.


Hi,
you shouldn't have more than one primary key in your table. Please compare your table structure with the following. The ONLY primary key is 'id'.
Change this and your CRUD generator should work. You can check this btw. using phpMyAdmin.

Here is the correct SQL up to chapter 6
--
-- Tabellenstruktur für Tabelle `tbl_issue`
--

CREATE TABLE `tbl_issue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`description` varchar(2000) DEFAULT NULL,
`project_id` int(11) DEFAULT NULL,
`type_id` int(11) DEFAULT NULL,
`status_id` int(11) DEFAULT NULL,
`owner_id` int(11) DEFAULT NULL,
`requester_id` int(11) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`create_user_id` int(11) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`update_user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_issue_project` (`project_id`),
KEY `FK_issue_owner` (`owner_id`),
KEY `FK_issue_requester` (`requester_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;


Let me know if this helps.

Peter
0

#3 User is offline   K22 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-March 11

Posted 17 March 2011 - 07:12 AM

View Postpietrop, on 15 March 2011 - 04:55 AM, said:

Hi,
you shouldn't have more than one primary key in your table. Please compare your table structure with the following. The ONLY primary key is 'id'.
Change this and your CRUD generator should work. You can check this btw. using phpMyAdmin.

Here is the correct SQL up to chapter 6
--
-- Tabellenstruktur für Tabelle `tbl_issue`
--

CREATE TABLE `tbl_issue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`description` varchar(2000) DEFAULT NULL,
`project_id` int(11) DEFAULT NULL,
`type_id` int(11) DEFAULT NULL,
`status_id` int(11) DEFAULT NULL,
`owner_id` int(11) DEFAULT NULL,
`requester_id` int(11) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`create_user_id` int(11) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`update_user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_issue_project` (`project_id`),
KEY `FK_issue_owner` (`owner_id`),
KEY `FK_issue_requester` (`requester_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;


Let me know if this helps.

Peter


That worked thx so much.
As a beginner I am having difficulties mostly cost by the errors in this book which is kinda frustrating so I might be back after some more chapters :-)
0

#4 User is offline   pietrop 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 24-February 11

Posted 17 March 2011 - 07:49 AM

The funny thing is, I made a lot of progress understanding yii BECAUSE of those errors in the book. It just made me think more. But you are right, there is a long list of errata, too long for my taste. This book sells for 40$, one would imagine a proof reader would be mandatory.
0

#5 User is offline   neverabe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-March 11

Posted 21 March 2011 - 12:35 PM

View PostK22, on 17 March 2011 - 07:12 AM, said:

As a beginner I am having difficulties mostly cost by the errors in this book which is kinda frustrating so I might be back after some more chapters :-)


Hello

I have the same error, i dropped and remake the table with information that was posted,
i erase protected/models/Issue.php and create again the model in the section model generator,

!!!but i still get the same error¡¡¡

Table 'tbl_issue' has a composite primary key which is not supported by crud generator.

Any clue about that?

Please help me i will appreciate
0

#6 User is offline   Pat M 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-July 12

Posted 12 July 2012 - 03:13 PM

After experiencing this issue using yii 1.1.10, I created a free online CRUD generator that works for tables with composite primary keys. Anybody having this problem can use the generator at http://www.handsoncoding.net

Currently the generated views look and function just like views that are created using gii. I will add in error handling though later on to prevent the ugly errors that appear when trying to delete a row from a table that is referenced by a child in another table.

I hope this is a time saver for everyone.
0

#7 User is offline   chinedui 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-July 12

Posted 24 July 2012 - 07:08 AM

Hello All;

I am quite new to yii and I find it a beautiful framework to use for my projects.

However I have run into an challenge. For some reason, All the code I used in the book up to chapter 6 works fine but my issue CRUD does not save data to the issue table. The Project CRUD still works fine so i decided to create another issue and Project CRUD to test and both failed to save to the database tables.

No error is given when this happens so I tried logging to see if I would have some idea of what might be wrong. I still couldn't find anything that gives me a solution.

Has any one come across this before and what may be a way out?

I would be most grateful for a reply.
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