Re: OOP slow -- am I an idiot?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10 Oct 2006, at 4:14 PM, Chris de Vidal wrote:

I think perhaps I'm using classes and OOP incorrectly. The last time I used them, they were slow.

I want to create a "customer" class which fetches its attributes from a MySQL database. Something
like this pseudocode:

class customer
    {
    ...
    getName ($id)
        {
$result = mysql_query ("SELECT name FROM customers WHERE id = '$id'");
        return mysql_result ($result, 0);
        }
    getRevenue ($id,$department,$month,$year)
        {
$result = mysql_query ("SELECT revenue FROM customer_revenue WHERE customer_id = '$id' AND
department = '$department' AND month = '$month' AND year = '$year'");
        return mysql_result ($result, 0);
        }
    ...
    }


You should look into getting Professional PHP5 by Lecky-Thompson, Eide-Goodman, Nowicki and Cove from WROX. It's a good introduction to using PHP5 with design patterns to solve problems similar to yours. Plus, the knowledge can be applied to other object oriented programming languages, not just PHP5. It's also been out for a while so it may be in the sale section already.

The collection class in chapter 5 discusses a programming problem just like yours.


Johan Martin
Catenare LLC
534 Pacific Ave
San Francisco, CA. 94133

http://www.catenare.com

http://www.linkedin.com/in/catenare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux