Basic class returns onject reference instead of Array
- by php-b-grader
I have very basic class:
class Customer {
protected $id;
protected $customer;
public function __construct($customer_id) {
$this->id = $customer_id;
return $this->set_customer();
}
protected function set_customer() {
$query = mysql_query("SELECT * FROM customer WHERE id = '$this->id'");
$this->customer = mysql_fetch_row($query);
return $this->customer;
}
}
$customer = new Customer($order->customer->id);
print_r($customer);
This is not doing what I want it to but I understand why... $customer returns a reference to the Customer Object... But what I want is the MySQL row array from the mysql_fetch_row() call...
What am I missing?