[Zope-dev] PHP vs Zope cost benefit

Oliver Bleutgen myzope@gmx.net
Tue, 23 Apr 2002 19:33:38 +0200


Jason Spisak wrote:
> You might remember me, I've been a big Zope fan since ZTables, 
> and have recently been asked "Why Zope?".  The project is 
> commited to PostgreSQL and leaning toward PHP.  Here's the 
> project requirements for a softwre company:
> 
> Hardware Compatability List
> Software Compatability List
> Store/ECommerce
> User tracking and services like 
>   Pay for downloads
>   Upgrades if they have a serial number paid up
> Billing/Invoicing for corporate accounts
> Inventory tracking
> CRM/Sales functions
> 
> 
> They don't see that Zope's built in security machinery would 
> beat something home brewed for what they expect to need it for. 
>  Plus the over head of running Zope instances is greater than 
> PHP scripts.  
> 
> What are the arguments for Zope in this context?
> 

Transaction Safety?

When reading your requirements that was the first thing coming into my 
mind. I don't know how php does this, so I went to google and found
http://www.phpbuilder.com/columns/linuxjournal200009.php3

Below is one snippet, notice all the ugly "//check for errors" and 
"//abort transaction". If someone knows where I misinterpret something 
or how php solves this, corrections welcome.

But wouldn't it be nice if we had an application server which would take 
care of all this for us?

Oh, wait ... ;-)

cheers,
oliver




function cart_new() {
     //make the database connection handle available
     global $conn,$customer_id,$feedback;

     //start a transaction
     query("BEGIN WORK");

     //query postgres for the next value in our sequence
     $res=query("SELECT nextval('seq_customer_id')");

     //check for errors
     if (!$res || pg_numrows($res)<1) {
         $feedback .= pg_errormessage($conn);
         $feedback .= ' Error - Database didn\'t return next value ';
         query("ROLLBACK");
         return false;
     } else {
         //set that value in a local var
         $customer_id=pg_result($res,0,0);

         //register the id with PHP4
         session_register('customer_id');

         //insert the new customer row
         $res=query("INSERT INTO customers (customer_id) VALUES 
('$customer_id')");

         //check for errors
         if (!$res || pg_cmdtuples($res)<1) {
             $feedback .= pg_errormessage($conn);
             $feedback .= ' Error - couldn\'t insert new customer row ';
             query("ROLLBACK");
             return false;
         } else {
             //commit this transaction
             query("COMMIT");
             return true;
         }
     }
}