I am wondering that whether it is possible to write two different mysql queries in one php class object method and use those results in an another class method. Here's I am trying to do (I put only the relevant part of my code here), but I think it's not working:
<?php
public function sql()
{
$sql = "SELECT * FROM customers";
// Another sql
$sql_sales = "SELECT SUM(sales) as sales FROM customers";
// Execute this sql and result is stored in a variable
$this->sales = $row['sales'];
return $sql;
}
public function customers_list()
{
$sql = $this->sql();
$customers = '
<div id="customers">
<div id="customers_num"><span>'.$this->sales.'</span> Sales</div>
</div>';
return $customers;
}
?>
Can we use value of variable $this->sales
inside another method?
If not then what's the correct way of getting it's value?