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

[eluser]avic[/eluser]
[I just realized that I posted this to the wrong forum, how do I delete the original 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]JHackamack[/eluser]
Unfortunately I haven't seen anything like that in CI and based on the loose structure of CI I don't believe I see it being built into CI. However if you are new to frameworks one suggestion I have heard floating around for DB integrity is CakePHP, and CakePHP has tools to generate the basic structure (if not more)
#3

[eluser]avic[/eluser]
Thanks,

There was a reason I ruled out CakePHP when evaluating frameworks, but I did a very quick eval before choosing CI, but I'll take another look at Cake.

-avi
#4

[eluser]avic[/eluser]
I am now reading the DMZ ORM (DataMapper Object Relational Mapper) docs, seems that it might be useful, but I am getting very tired, will continue tomorrow.

-avi

Quote:DataMapper is an Object Relational Mapper written in PHP for CodeIgniter. It is designed to map your Database tables into easy to work with objects, fully aware of the relationships between each other.

Quote:HTML Form Generation Methods (htmlform)
Uses properties from a DataMapper object to quickly generate forms. This method is highly customizable, both in a broad sense, and on a field-by-field basis. When combined with the Associative Array Conversion Methods, this extension can make creating simple content mangement tools very easy.
#5

[eluser]JHackamack[/eluser]
Also look at: http://www.widgetpress.com/modelbaker one of my group members used it to do the default setting up and relationships. I will say CakePHP wasn't the easiest for me to grasp, and i do prefer CI for the looseness, but since you're looking for strict framework in a few days time this might be the best tool for the job. I just don't want people to get the impression im a CI basher. Wink
#6

[eluser]Fabdrol[/eluser]
Dude. You wanna built that in under 2 days? I'd start up by buying A LOT of coffee, before you start Tongue
Success!
#7

[eluser]Jondolar[/eluser]
You might want to use Doctrine or one of the ORM libraries in the wiki.




Theme © iAndrew 2016 - Forum software by © MyBB