How does one know when to put variables into the class rather than inside the class functions? For example - This database class is instantiated by its sub-class and it also instantiates its sub-class. It has no class variables.
class database extends one_db { function __construct() { one_db::get(); } public function pdo_query() { } public function query($query) { return one_db::$db->query($query); } private function ref_arr(&$arr) // pdo_query will need this later. { $refs = array(); foreach($arr as $key => $value) { $refs[$key] = &$arr[$key]; } return $refs; } } Howeve I could just as well pull out the $query variabe like this
class database extends one_db { protected $query; function __construct() { one_db::get(); } public function pdo_query() { } public function query($query) { $this->query=$query return one_db::$db->query($this->query); } private function ref_arr(&$arr) // pdo_query will need this later. { $refs = array(); foreach($arr as $key => $value) { $refs[$key] = &$arr[$key]; } return $refs; } } I would assume that this only needs to be done when the variable is shared between multiple class functions but I'm not too sure.