Re: Suggestions for class design

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

 



Chris W. Parker wrote:
<snip>

>>
>> class Customer
>> {
>> 	var $id;
>> 	var $name;

<snip>
<snip>

>> 	function get_customer()
>> 	{

<snip>
<snip>


	$this->name = $customer['name'];

>> 	}

<snip>

>> Where I get tripped up is when I realize I'll need to at some point get
>> more than one customer at a time and thus I want to add a method called
>> 'get_customers()'.

<snip>

Hi Chris

Assuming that you have some procedural code, could you not create an
array of Customer objects?
I am not sure what argument would be passed to the get_customer function
as you do not have an argument in the function definition, but if it was
perhaps the customer name, you coud have something like :

/*Procedural code*/

$get_customer_names = 'SELECT ... FROM .... WHERE customer ADDRESS LIKE
....';

$customer_name_result_set = $db_connection->query($get_customer_names);

for($i=0; $i < $customer_name_result_set->num_rows; $i++) {

	$customer_name_result_record = $customer_name_result_set->fetch_row();

	$customers[$i] = new Customer;
	$customers[$i]->get_customer($customer_name_result_record[0]);


}

That's how I would do it, at any rate (which is probably no
recommendation  ;)  ).

Regards

Rory

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