[ciapug] On or Off ...

Tony Bibbs tony at tonybibbs.com
Tue Aug 23 08:54:35 CDT 2005



Carl Olsen wrote:
> I got really deep into object oriented PHP this weekend and decided to start
> with something a little more simple, so I'm creating a class for each table
> with select, insert, update, and delete functions that all use prepared
> statements.  I agree that the security blanket is great.  

When you get done with all of this and have time to breathe, you should 
really consider looking at Propel, http://prople.phpdb.org.  That tool 
creates a set of object from your database (generally one class per 
table).  These objects are pure PHP objects that the Propel runtime can 
then use to do all your insert/update/delete logic magically.  Thus you 
could have something like:

// Retrieve existing customer
$customer = new Customer();
$customer->setId(5);
$customer->get();

// Create an order
$order = new Order();
$order->setProductCode(4);
$order->setUnitPrice(20.00);
$order->setQuantity(3);

// Assign order to customer
$customer->addOrder($order);

// Save it all
$customer->save();

This gets you out of the business of writing a lot of SQL and underneath 
it uses prepared statements.

--Tony


More information about the ciapug mailing list