Código PHP:
class Products {
public function list_products() {
$query = mysql_query("SELECT * FROM products") or die(mysql_error());
while($row = mysql_fetch_array($query))
{
$name = $row['name'];
$price = $row['price'];
$this->products->array('name' => $name, 'price' => $price);
}
}
}
Código PHP:
$products = new Products();
$products->list_products();