Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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
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 ]

[Page 1]  [Page 2]  


Comments:
RE: Bad practice in this exampleBen11/07/05 08:38
RE: Problem with database variablesThomas Noller01/11/05 15:36
RE: Bad practice in this exampleThomas Noller01/11/05 15:29
Freedom of Choicenick01/06/05 19:14
Fits the real world? A vague claimTablizer12/29/04 23:13
RE: Why stop at procedural programming?edis tamoshauskas11/26/04 10:13
RE: OO logic is king (but PHP OO sucks)Steve L08/18/04 09:52
RE: "Printable" version, well....isn't printaShai06/29/04 17:40
RE: Why stop at procedural programming?Tablizer06/15/04 03:17
Why stop at procedural programming?Pootle05/11/04 11:07
RE: Is this better?acerola04/18/04 00:31
Hierarchies Limited (RE: OO vs. procedural?)Topmind04/03/04 14:34
using 'AND' queries with mysqldb classsandy4door12/18/03 14:13
security aspect - constants.incAlex Haid11/26/03 09:09
RE: No need for Get* and Set*mmj07/02/03 10:20
your script sucksMindLock04/09/03 02:51
even more mistakesgee01/24/03 05:06
This ...gee01/24/03 04:45
OOP Criticism WebsiteTablizer01/10/03 17:18
RE: OO logic is king (but PHP OO sucks)Captain Proton12/19/02 12:53
RE: ConnectionDavide12/19/02 06:16
using classes to make your content portable.Armand Krijgsman11/25/02 05:28
RE: OO logic is king (but PHP OO sucks)Diego11/19/02 22:32
RE: OO logic is king (but PHP OO sucks)Simon62210/25/02 17:11
RE: OO logic is king (but PHP OO sucks)Diego09/29/02 14:18
ConnectionAldrey08/22/02 07:30
Could there be "some" mistakes?C-Man08/22/02 03:58
RE: Perl to PHP ObjectsAnas Mughal08/13/02 14:02
RE: OO vs. procedural?Anas Mughal08/13/02 13:46
RE: return referencesMartin08/13/02 04:42
RE: OO logic is kingRemmelt08/01/02 10:59
RE: OO logic sucksTom Myer07/30/02 01:45
RE: OO logic sucksMike Miller07/25/02 00:23
Global Array???Abhishek Lahare07/12/02 11:11
RE: Object's ArrayEduardo Ramírez06/18/02 01:23
No need for Get* and Set*Stuart06/15/02 15:50
RE: OO logic sucksTablizer06/13/02 13:42
Problem with require ("file");kellog05/30/02 18:45
Why OO in PHP?Bastien05/29/02 10:44
Can't call the same method more than onceRobertoL05/10/02 04:09
RE: Advantages of OO ?crimaniak05/07/02 20:32
RE: Object's ArrayPaul Marconi04/28/02 12:19
RE: Destructor on PHPArnaud04/11/02 13:43
Destructor on PHPpoiu04/05/02 17:05
RE: **real** OO ? have a look at ZopeIan Ferger03/18/02 20:19
why mysql is not supporitng foreign key concesatish mishra03/13/02 06:27
Advantages of OOKarim Ahmed02/11/02 13:58
security vulnerabilityBijan Fathi02/10/02 17:36
this example is full of bugsradiator12/27/01 08:33
about Object Oriented PHP articlevictor12/19/01 13:02
RE: error when tried to connecting to web serverdaniel12/14/01 07:10
RE: error when tried to connecting to web serverNans12/13/01 11:20
RE: Undeclared variableiancforsyth12/10/01 18:01
Use function to get & set values ???Kelvin Sun11/23/01 19:10
RE: Object's ArrayLennie10/28/01 06:06
OO vs. procedural?Ron MacNeil09/25/01 19:44
Error in code on page 4Martin Jørgensen08/09/01 08:15
Undeclared variablepa_bryan07/23/01 23:01
Advantages of OO ?Bernd vd Brincken07/11/01 07:10
error when tried to connecting to web serverHarry C. Sihombing07/09/01 18:47
RE: U HAVE A PROBLEM!!!!Torsten Kammeyer06/19/01 01:58
pharse error?Chaloupka05/27/01 02:04
RE: Cool idea, but.....Charles Palmer05/19/01 12:22
Might be betterEdis Tamoshauskas05/18/01 15:05
Object's Arrayana05/09/01 05:47
U HAVE A PROBLEM!!!!Dolce04/25/01 06:31
RE: "Bug" in this example..Rob04/24/01 13:18
RE: OO logic sucksKen Egervari03/19/01 18:54
PHP, MySQL and objectsMike02/26/01 18:29
OO logic sucksDan Melomedman02/23/01 09:17
mysql.classMark Tonino02/01/01 05:44
**real** OO ? have a look at ZopeDidier01/20/01 10:14
RE: Classes into classes.bill01/04/01 20:36
RE: Classes into classes.bill01/04/01 20:24
Classes into classes.Juan12/13/00 15:40
RE: Is this better?Carsten12/04/00 16:08
Cool idea, but.....Dharssi11/30/00 15:12
RE: Is this better?Gyuro Lehel11/30/00 12:37
Great Eye OpenerDinesh11/28/00 04:35
"Bug" in this example..Eljon Greene09/06/00 17:13
RE: Perl to PHP ObjectsAdrian Kubala08/15/00 17:31
RE: I'm confusedIlja Heitlager08/14/00 18:44
I'm confusedJoe Fan08/14/00 04:43
Object HTMLMichael Ogmios08/09/00 23:17
RE: Prob. with database variablesOmar Rosado08/08/00 17:04
Great, thanksFlorian Oefinger08/06/00 13:55
general commentVincent Vollers08/05/00 16:42
RE: return referencesVincent Vollers08/05/00 16:36
RE: return referencesChris Moylan08/03/00 03:48
RE: Is this better? (short answer: yes)Jeffery Cann08/02/00 18:07
RE: Is this better?Dean Williams08/01/00 23:45
RE: "Printable" version, well....isn't pAndy Rush08/01/00 15:14
RE: Is this better?Frederic De Leersnijder08/01/00 03:57
RE: Is this better?Chuck Gebhard07/31/00 16:48
PHP OO and performanceJens-Petter Salvesen07/31/00 11:02
return referencesJason Miller07/31/00 10:34
Global vars??Juan Borrás07/31/00 03:05
RE: Bad practice in this exampleKyle Olsen07/28/00 17:39
RE: Is this better?Tim Perdue, PHPBuilder.com07/28/00 02:21
RE: "Printable" version, well....isn't pTim Perdue, PHPBuilder.com07/28/00 02:17
Problem with database variableskory gray07/28/00 00:54
RE: Bad practice in this exampletom07/27/00 17:31
"Printable" version, well....isn't printableBrian Sugrue07/27/00 17:02
RE: Bad practice in this exampleTom Anderson07/27/00 15:55
Is this better?Neil Moomey07/27/00 14:18
Bad practice in this exampleKyle Olsen07/27/00 14:03
RE: Perl to PHP ObjectsAdam Constabaris07/27/00 10:24
Perl to PHP ObjectsFred Hirsch07/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.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.