|
Posted by Rory McKinley on 09/19/05 21:45
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
Navigation:
[Reply to this message]
|