Basic class returns onject reference instead of Array
Posted
by php-b-grader
on Stack Overflow
See other posts from Stack Overflow
or by php-b-grader
Published on 2010-05-27T01:43:18Z
Indexed on
2010/05/27
1:51 UTC
Read the original article
Hit count: 252
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?
© Stack Overflow or respective owner