|
Object Oriented PHP
Development Process
As always, we will start by defining our global constants, then we'll move onto create our
data schema (and database), followed by our data class, then our box classes and finally, we'll create
the .phtml file, which will bring it all together into a working example - or at least, that's the plan
at the moment!
Constants
This is a straight forward PHP file, which I create to define Constant values I can use
across a whole site. By using this - appropriately - I can change the look/feel of a site from one
place, rather than having to chase variable values across multiple pages. Here's our constants.inc sample:
<?php
// Database Constants
$HOST = "localhost";
$DB = "testing";
$WEBUSER = "root";
$WEBPASSWORD = "";
// Colour Constants
$COLOR_PRIMARY = "#037B0B";
$COLOR_SECONDARY = "#FFFFC0";
$COLOR_TERTIARY = "#ECED81";
// Value Constants
$TRUE = 1;
$FALSE = 0;
// Application Specific
$TITLE = "Object Orientation Demonstration";
$ADMINEMAIL = "webmaster@domin.com";
// CSS Plug-in Values
$CSSBOXTITLE = "boxtitle";
?>
Database Schema
Under no circumstances should this be taken as a de-facto database schema, but it works for
the purposes of this example:
![[Image:] Entities & Relationships](mark20000727_relationships.gif)
As you can see, the data for News is in a table in its own right, whilst the race, driver,
team and points details are the result of related tables. Suffice to say, if you do not understand
this schema, you should go and read up on some RDBMS introductory material before going any further.
[ Next Page ]
| Comments: | ||
| RE: Bad practice in this example | Ben | 11/07/05 08:38 |
| RE: Problem with database variables | Thomas Noller | 01/11/05 15:36 |
| RE: Bad practice in this example | Thomas Noller | 01/11/05 15:29 |
| Freedom of Choice | nick | 01/06/05 19:14 |
| Fits the real world? A vague claim | Tablizer | 12/29/04 23:13 |
| RE: Why stop at procedural programming? | edis tamoshauskas | 11/26/04 10:13 |
| RE: OO logic is king (but PHP OO sucks) | Steve L | 08/18/04 09:52 |
| RE: "Printable" version, well....isn't printa | Shai | 06/29/04 17:40 |
| RE: Why stop at procedural programming? | Tablizer | 06/15/04 03:17 |
| Why stop at procedural programming? | Pootle | 05/11/04 11:07 |
| RE: Is this better? | acerola | 04/18/04 00:31 |
| Hierarchies Limited (RE: OO vs. procedural?) | Topmind | 04/03/04 14:34 |
| using 'AND' queries with mysqldb class | sandy4door | 12/18/03 14:13 |
| security aspect - constants.inc | Alex Haid | 11/26/03 09:09 |
| RE: No need for Get* and Set* | mmj | 07/02/03 10:20 |
| your script sucks | MindLock | 04/09/03 02:51 |
| even more mistakes | gee | 01/24/03 05:06 |
| This ... | gee | 01/24/03 04:45 |
| OOP Criticism Website | Tablizer | 01/10/03 17:18 |
| RE: OO logic is king (but PHP OO sucks) | Captain Proton | 12/19/02 12:53 |
| RE: Connection | Davide | 12/19/02 06:16 |
| using classes to make your content portable. | Armand Krijgsman | 11/25/02 05:28 |
| RE: OO logic is king (but PHP OO sucks) | Diego | 11/19/02 22:32 |
| RE: OO logic is king (but PHP OO sucks) | Simon622 | 10/25/02 17:11 |
| RE: OO logic is king (but PHP OO sucks) | Diego | 09/29/02 14:18 |
| Connection | Aldrey | 08/22/02 07:30 |
| Could there be "some" mistakes? | C-Man | 08/22/02 03:58 |
| RE: Perl to PHP Objects | Anas Mughal | 08/13/02 14:02 |
| RE: OO vs. procedural? | Anas Mughal | 08/13/02 13:46 |
| RE: return references | Martin | 08/13/02 04:42 |
| RE: OO logic is king | Remmelt | 08/01/02 10:59 |
| RE: OO logic sucks | Tom Myer | 07/30/02 01:45 |
| RE: OO logic sucks | Mike Miller | 07/25/02 00:23 |
| Global Array??? | Abhishek Lahare | 07/12/02 11:11 |
| RE: Object's Array | Eduardo Ramírez | 06/18/02 01:23 |
| No need for Get* and Set* | Stuart | 06/15/02 15:50 |
| RE: OO logic sucks | Tablizer | 06/13/02 13:42 |
| Problem with require ("file"); | kellog | 05/30/02 18:45 |
| Why OO in PHP? | Bastien | 05/29/02 10:44 |
| Can't call the same method more than once | RobertoL | 05/10/02 04:09 |
| RE: Advantages of OO ? | crimaniak | 05/07/02 20:32 |
| RE: Object's Array | Paul Marconi | 04/28/02 12:19 |
| RE: Destructor on PHP | Arnaud | 04/11/02 13:43 |
| Destructor on PHP | poiu | 04/05/02 17:05 |
| RE: **real** OO ? have a look at Zope | Ian Ferger | 03/18/02 20:19 |
| why mysql is not supporitng foreign key conce | satish mishra | 03/13/02 06:27 |
| Advantages of OO | Karim Ahmed | 02/11/02 13:58 |
| security vulnerability | Bijan Fathi | 02/10/02 17:36 |
| this example is full of bugs | radiator | 12/27/01 08:33 |
| about Object Oriented PHP article | victor | 12/19/01 13:02 |
| RE: error when tried to connecting to web server | daniel | 12/14/01 07:10 |
| RE: error when tried to connecting to web server | Nans | 12/13/01 11:20 |
| RE: Undeclared variable | iancforsyth | 12/10/01 18:01 |
| Use function to get & set values ??? | Kelvin Sun | 11/23/01 19:10 |
| RE: Object's Array | Lennie | 10/28/01 06:06 |
| OO vs. procedural? | Ron MacNeil | 09/25/01 19:44 |
| Error in code on page 4 | Martin Jørgensen | 08/09/01 08:15 |
| Undeclared variable | pa_bryan | 07/23/01 23:01 |
| Advantages of OO ? | Bernd vd Brincken | 07/11/01 07:10 |
| error when tried to connecting to web server | Harry C. Sihombing | 07/09/01 18:47 |
| RE: U HAVE A PROBLEM!!!! | Torsten Kammeyer | 06/19/01 01:58 |
| pharse error? | Chaloupka | 05/27/01 02:04 |
| RE: Cool idea, but..... | Charles Palmer | 05/19/01 12:22 |
| Might be better | Edis Tamoshauskas | 05/18/01 15:05 |
| Object's Array | ana | 05/09/01 05:47 |
| U HAVE A PROBLEM!!!! | Dolce | 04/25/01 06:31 |
| RE: "Bug" in this example.. | Rob | 04/24/01 13:18 |
| RE: OO logic sucks | Ken Egervari | 03/19/01 18:54 |
| PHP, MySQL and objects | Mike | 02/26/01 18:29 |
| OO logic sucks | Dan Melomedman | 02/23/01 09:17 |
| mysql.class | Mark Tonino | 02/01/01 05:44 |
| **real** OO ? have a look at Zope | Didier | 01/20/01 10:14 |
| RE: Classes into classes. | bill | 01/04/01 20:36 |
| RE: Classes into classes. | bill | 01/04/01 20:24 |
| Classes into classes. | Juan | 12/13/00 15:40 |
| RE: Is this better? | Carsten | 12/04/00 16:08 |
| Cool idea, but..... | Dharssi | 11/30/00 15:12 |
| RE: Is this better? | Gyuro Lehel | 11/30/00 12:37 |
| Great Eye Opener | Dinesh | 11/28/00 04:35 |
| "Bug" in this example.. | Eljon Greene | 09/06/00 17:13 |
| RE: Perl to PHP Objects | Adrian Kubala | 08/15/00 17:31 |
| RE: I'm confused | Ilja Heitlager | 08/14/00 18:44 |
| I'm confused | Joe Fan | 08/14/00 04:43 |
| Object HTML | Michael Ogmios | 08/09/00 23:17 |
| RE: Prob. with database variables | Omar Rosado | 08/08/00 17:04 |
| Great, thanks | Florian Oefinger | 08/06/00 13:55 |
| general comment | Vincent Vollers | 08/05/00 16:42 |
| RE: return references | Vincent Vollers | 08/05/00 16:36 |
| RE: return references | Chris Moylan | 08/03/00 03:48 |
| RE: Is this better? (short answer: yes) | Jeffery Cann | 08/02/00 18:07 |
| RE: Is this better? | Dean Williams | 08/01/00 23:45 |
| RE: "Printable" version, well....isn't p | Andy Rush | 08/01/00 15:14 |
| RE: Is this better? | Frederic De Leersnijder | 08/01/00 03:57 |
| RE: Is this better? | Chuck Gebhard | 07/31/00 16:48 |
| PHP OO and performance | Jens-Petter Salvesen | 07/31/00 11:02 |
| return references | Jason Miller | 07/31/00 10:34 |
| Global vars?? | Juan Borrás | 07/31/00 03:05 |
| RE: Bad practice in this example | Kyle Olsen | 07/28/00 17:39 |
| RE: Is this better? | Tim Perdue, PHPBuilder.com | 07/28/00 02:21 |
| RE: "Printable" version, well....isn't p | Tim Perdue, PHPBuilder.com | 07/28/00 02:17 |
| Problem with database variables | kory gray | 07/28/00 00:54 |
| RE: Bad practice in this example | tom | 07/27/00 17:31 |
| "Printable" version, well....isn't printable | Brian Sugrue | 07/27/00 17:02 |
| RE: Bad practice in this example | Tom Anderson | 07/27/00 15:55 |
| Is this better? | Neil Moomey | 07/27/00 14:18 |
| Bad practice in this example | Kyle Olsen | 07/27/00 14:03 |
| RE: Perl to PHP Objects | Adam Constabaris | 07/27/00 10:24 |
| Perl to PHP Objects | Fred Hirsch | 07/27/00 09:17 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


