Sample web application – PHP

  php

Q(Question):

For those of you who are interested I have made some transactions from
my sample web application available on my website. They are described
in http://www.tonymarston.net/php-mysql…plication.html

This contains a link to where you can run the transactions online, and
there is another link where you can download all the necessary code to
run offline in your own PHP environment.

Be aware that this code is not for the novice as it contains the
following features:

– It is built around a *proper* 3 tier architecture as there are
totally separate scripts which deal with the data access, business and
presentation layers.

– The data access layer is provided by a DML object which issues all
DML/SQL statements (this version is for MySQL).

– The business layer is comprised of an abstract database class with a
separate subclass for each physical database table. The abstract class
contains a great deal of generic and reusable code, while each
subclass only contains code which is specific to its database table.
There is a separate validation object which deals with
generic/standard/declarative validation.

– The presentation layer (user interface) is comprised of two types of
script: a set of resuable dialog-type scripts which perform specific
actions on specific data structures, and a set of component scripts
which basically do nothing but call one of the dialog-type scripts
with the identity of the objects to work on.

– All HTML output is done via XML with XSL transformations. The XSL
files come in two categories: a set of component templates which deal
with each database table, plus a set of generic reusable templates
which are responsible for creating the HTML code for each type of
control.

Try it. Run it. Download it. Play with it. Examine it.

Don’t applaud, just throw money!

Tony Marston
http://www.tonymarston.net/

A(Answer):

Hi Tony!

On 10 Nov 2003 08:39:37 -0800, to**@marston-home.demon.co.uk (Tony
Marston) wrote:

For those of you who are interested I have made some transactions from
my sample web application available on my website. They are described
in http://www.tonymarston.net/php-mysql…plication.html

(…)

Looks very nice and interesting. I have done something similar, but
not separated it so well, as it grew with time. I have to have a look
later to learn something…

Jochen

Jochen Daum – CANS Ltd.
PHP DB Edit Toolkit — PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

A(Answer):

On 10 Nov 2003 08:39:37 -0800, to**@marston-home.demon.co.uk (Tony
Marston) wrote:

For those of you who are interested I have made some transactions from
my sample web application available on my website. They are described
in http://www.tonymarston.net/php-mysql…plication.html

I must add, that I’m positively surprised that you use arrays for the
database class. This seems the best solution to me as well with PHP,
but a lot of people stick to the

$obj->field

solution still.

Jochen

Jochen Daum – CANS Ltd.
PHP DB Edit Toolkit — PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

A(Answer):

Tony Marston wrote:

in http://www.tonymarston.net/php-mysql…plication.html
Don’t applaud, just throw money!

Dude, that is a shitload of good work!
I haven’t read every article but I’ve skimmed. I will refer back to it
when dealing with specific topics. I’ve taken different approaches to
similar problems. I think I can benefit learning alternate methods.
Love the nice XSL article, just the right size for the XSL newbie (even
though you say some experience is required). Nice recipes there.
Good to see the use of XSLT in your dialog-types too — can’t understand
why every second PHP developer is coming up with his/her own unique
templating system when the W3C already has a very good one.

Well done.

Hey everyobody, come look!

<<applauds anyway (too poor to throw money)>>

A(Answer):

Jochen Daum <jo*********@cans.co.nz> wrote in message news:<23********************************@4ax.com>. ..

On 10 Nov 2003 08:39:37 -0800, to**@marston-home.demon.co.uk (Tony
Marston) wrote:

For those of you who are interested I have made some transactions from
my sample web application available on my website. They are described
in http://www.tonymarston.net/php-mysql…plication.html

I must add, that I’m positively surprised that you use arrays for the
database class. This seems the best solution to me as well with PHP,
but a lot of people stick to the

$obj->field

solution still.

Jochen

I cannot see the point of extracting data from each object one field
at a time when the whole row can be passed as an associative array.
This method also avoids the necessity of having field names hard-coded
everywhere. If you look at my code which creates the XML document you
will see that there are no field names hard-coded anywhere – it just
takes the contents of the array (which may hold any number of rows)
and throws it into an XML document. Thus I have been able to create a
single standard function which creates XML files. I think this is a
good example of ‘write once – use many’ which is an objective that
every competent programmer should aim for.

Did you notice how I also use arrays to construct the INSERT and
UPDATE statements using generic code? I have seen examples where
people have hard-coded these for each individual table. How
inefficient is that?

Tony Marston
http://www.tonymarston.net/

A(Answer):

Hi !

On 11 Nov 2003 01:01:03 -0800, to**@marston-home.demon.co.uk (Tony
Marston) wrote:

Jochen Daum <jo*********@cans.co.nz> wrote in message news:<23********************************@4ax.com>. ..

On 10 Nov 2003 08:39:37 -0800, to**@marston-home.demon.co.uk (Tony
Marston) wrote:

>For those of you who are interested I have made some transactions from
>my sample web application available on my website. They are described
>in http://www.tonymarston.net/php-mysql…plication.html
>

I must add, that I’m positively surprised that you use arrays for the
database class. This seems the best solution to me as well with PHP,
but a lot of people stick to the

$obj->field

solution still.

Jochen

I cannot see the point of extracting data from each object one field
at a time when the whole row can be passed as an associative array.
This method also avoids the necessity of having field names hard-coded
everywhere. If you look at my code which creates the XML document you
will see that there are no field names hard-coded anywhere – it just
takes the contents of the array (which may hold any number of rows)
and throws it into an XML document. Thus I have been able to create a
single standard function which creates XML files. I think this is a
good example of ‘write once – use many’ which is an objective that
every competent programmer should aim for.

Did you notice how I also use arrays to construct the INSERT and
UPDATE statements using generic code? I have seen examples where
people have hard-coded these for each individual table. How
inefficient is that?

From the size of your answer it looks like you disagree. But you
don’t. I do it exactly the same way.

Jochen

Jochen Daum – CANS Ltd.
PHP DB Edit Toolkit — PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

A(Answer):

Terence <tk******@fastmail.fm> wrote in message news:<3F**************@fastmail.fm>…

Tony Marston wrote:

in http://www.tonymarston.net/php-mysql…plication.html

Don’t applaud, just throw money!

Dude, that is a shitload of good work!
I haven’t read every article but I’ve skimmed. I will refer back to it
when dealing with specific topics. I’ve taken different approaches to
similar problems. I think I can benefit learning alternate methods.
Love the nice XSL article, just the right size for the XSL newbie (even
though you say some experience is required). Nice recipes there.
Good to see the use of XSLT in your dialog-types too — can’t understand
why every second PHP developer is coming up with his/her own unique
templating system when the W3C already has a very good one.

This also means that I would find it easier to upgrade to XFORMS (the
new W3C standard) as soon as compatible browsers become available.

Tony Marston
http://www.tonymarston.net/

Well done.

Hey everyobody, come look!

<<applauds anyway (too poor to throw money)>>

LEAVE A COMMENT