I had 5 minutes, and CakePHP.

Sunday, April 1. 2007

I had five minutes to do something before I decided that I wanted to watch a movie...I'm now putting that off simply to report back on what I got out of my time.

For the background information...I just discovered that the person traditionally in charge of handling my high school's class reunions, is out of the country and could probably care less over handling everything...so we need something up quick and dirty.
Here's the database dump:

Here's the Model code:

...and here's the Controller code:

In a matter of about 5 minutes, I had a fully working website based access page for this table that will work in both PHP4 and PHP5 (thus the usage of var instead of public -- so don't use this in E_STRICT under PHP5). Obviously, I have a lot more work ahead of me, but for simple things, you can certainly imagine how nice this is. It's quite helpful for more in-depth things as well. ;)

To reiterate:
1.) Create database (I used a GUI, so it was even quicker).
2.) Create PHP model class, extending default AppModel in CakePHP.
3.) Create scaffolded Controller.
4.) Save
5.) View
6.) ...done...

Just for clarification, I do know that the plural of Alumni is Alumns, not Alumnis...but I was in a hurry and couldn't remember where to find the file that handles plural forms of words to check and see if Alumni was listed anywhere...so I did it this way, albeit incorrect, but safer programatically, for the time being.

I just realized that in those 2 minutes I took to think up and create the database table, I missed a couple important fields, such as password and email address. To take care of this accidental oversight, there is no PHP code that needs to be modified. I could modify the model class for validation handling, but it's not necessary -- the scaffolding will still automatically detect the proper fields and magically change the PHP form used to manipulate the data. Instead, all that needs to be modified is the database table(s).


Trackback specific URI for this entry
    No Trackbacks


    #1 Jen on 05/06/07 at 09:36 PM [Reply]
    Cool! I'm just getting started with learning CakePHP and I'm already astounded at how quick it is to do things (and I'm just learning PHP as well!). Nice to see the basic steps laid out for newbies like me.

    #1.1 Brendon Kozlowski on 05/12/07 at 11:13 AM [Reply]

    Although you're an automated response (as governed by your referring URL and original -deleted- homepage address), I appreciate the feedback. ;)

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

BBCode format allowed