Wednesday, May 27, 2009

Re: How do I bake pre-existing tables with non-conforming names?

Any updates on this?

On Tue, May 26, 2009 at 1:41 PM, Jorge Garifuna <garifuna@gmail.com> wrote:
I have a few database tables that were created several years ago and
are now heavily dependent upon for pre-existing components.

I would like to use cakePHP to bake a portion of the application to
make publically available. My issues is that the command "cake bake
all" is failing the create the models because the plural name of the
table does not exist.

These pre-existing tables use singular names and the primary fields
names is prefixed with the table names (eg: table "user", primary key
"user_id").

 Below is a simplified listing of some of these tables:


CREATE  TABLE IF NOT EXISTS `user` (
 `user_id` INT(10) NOT NULL AUTO_INCREMENT ,
 `login` VARCHAR(25) NOT NULL ,
 `password` VARCHAR(50) NOT NULL ,
 `active` TINYINT(1) UNSIGNED NULL DEFAULT 0 ,
 PRIMARY KEY (`user_id`)
);


CREATE  TABLE IF NOT EXISTS `video_item` (
 `video_item_id` INT(10) NOT NULL AUTO_INCREMENT ,
 `title` VARCHAR(255) NOT NULL ,
 `icon_image` VARCHAR(255) NULL ,
 `video_file` VARCHAR(255) NULL ,
 `description` TEXT NULL ,
 `active` TINYINT(1) NULL ,
 PRIMARY KEY (`video_item_id`)
);



CREATE  TABLE IF NOT EXISTS `video_comment` (
 `video_comment_id` INT(10) NOT NULL AUTO_INCREMENT ,
 `video_item_id` INT(10) NOT NULL ,
 `subject` VARCHAR(255) NOT NULL ,
 `comment` TEXT NOT NULL ,
 PRIMARY KEY (`video_comment_id`)
);

As you can see the names and primary keys of these tables are:

user/user_id, video_item/video_item_id and video_comment/
video_comment_id

and cake bake expects them to be:

users/id, video_items/id and video_comments/id

Since these tables are already used internally within other systems,
it would be very time consuming to review all the dependencies within
the existing systems to make them conform to cakePHP naming
convention.

Is there a way to use the command "cake bake all" with some minor
tweaking so that the models, controllers and views are created with
the existing name of the tables?

Any assistance would be greatly appreciated.

Jorge



--
Jorge Garifuna
Professional Web Developer
"Your Web Solution Partner"
Garinet Media Network, LLC.
811 Wilshire Blvd. Suite 1705
Los Angeles, CA 90017
http://www.GariDigital.com
Business Operating Hours: Monday - Friday: 9AM - 6 PM PST

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: