Welcome Guest, Not a member yet? Register   Sign In
Quickest way to create CI application to manage existing MySQL database, enforcing referential integrity.
#1

[eluser]avic[/eluser]
[I believe that this is the wrong forum, so I reposted this at http://ellislab.com/forums/viewthread/140856/ how do I delete this post?]

Hi All,

I have less than two days to build a small app that will manage an existing MySQL database (about two dozen tables, all related either via one-to-many or many-to-many)

By manage I mean not just the std CRUD stuff, but also enforcing database referential integrity, and entity integrity.

Since the users have no knowledge of the database schema and relationships, the app will have to enforce the database referential integrity, i.e. not to allow a deletion of a record which is related by another record, or when creating a new entry, allow a selection of related records via a pull down (or an in-line creation of a new related record, i.e. if the desired value is not in the pull-down, allow simultaneous creation of both records, and if that new related record needs to relate to yet a third table... ) so that the new records will always relate to valid records, etc.

Similarly for entity integrity, since some columns can only contain specific data values, defined as SQL enum data type, I do not want to give user a plain text entry field. For these I would like the PHP code to pull the values from the table structure enum values. (so that I do not have to maintain the PHP code when a new data value is added to the SQL enum)

I do know PHP and SQL fairly well, and designed the database schema and a separate SQL query/reporting web application (done in a Java based wiki, which very limited in its database ability, I can only do SQL queries, no scripting at all, so I am not even able to do data validation, not to mention enforcing referential integrity)

Until now I just used phpMyAdmin to manage/maintain the database, but by Tuesday, I have to create a "user friendly" interface to manage the database.

I am a brand new CI user, just downloaded and installed it a few minutes ago so I pretty much know nothing about it, I've seen some of the CRUD examples, but none seem to enforce db integrity.

Is there a way to automagically generate PHP code from the existing database schema to speed up development?

i.e. classes/functions/methods for the database tables, code for CRUD forms (i.e. given a two or more related database tables, automagically create an HTML form for all the columns, pulling data from the database to populate pull-downs, related records, etc)

Does CI have any facility to enforce database integrity?

thank you so much

-avi
#2

[eluser]jedd[/eluser]
[quote author="avic" date="1263026801"]
I have less than two days to build a small app that will manage an existing MySQL database (about two dozen tables, all related either via one-to-many or many-to-many)

. . .

Until now I just used phpMyAdmin to manage/maintain the database, but by Tuesday, I have to create a "user friendly" interface to manage the database.

. . .

I am a brand new CI user, just downloaded and installed it a few minutes ago so I pretty much know nothing about it, I've seen some of the CRUD examples, but none seem to enforce db integrity.
[/quote]

a) Tuesday is more than two days away ( no matter where you are on the planet)
b) Don't do this. Learn CI separately to rushing through a non-trivial project. If you're competent with MySQL / PHP - stick with what you know on this kind of gig, and then, later, learn the framework properly.

Quote:Is there a way to automagically generate PHP code from the existing database schema to speed up development?

CRUD stuff - yes - look for CRUD in the wiki.

Consider an ORM (DMZ's for example).

Quote:Does CI have any facility to enforce database integrity?

I think you'll find this is left in the hands of the DB designer (normalise your DB, use FK's etc), your DB interface (design competent models) and your coder (write good PHP).




Theme © iAndrew 2016 - Forum software by © MyBB