update_point() i delete_point()
$user_point = 2; class sql { //dopisujemy parę funkcji do klasy Eps public function update(Eps $update) { } public function remove(Eps $remove) { } } abstract class Eps_Cat_Point { // Dane beda pochodzic z bazy // Litera to identyfikator kategorii za co dostaje sie pkt np A za artykul 3 pkt. } class Eps extends Eps_Cat_Point { public $user_id; public $cat_point; public $query; public $method_name; public function __construct($user_id, $cat_point, $method_name) { $this->user_id = $user_id; $this->cat_point = $cat_point; if(method_exists(__CLASS__, $method_name)){ $this->method_name = $method_name; ///$sql = new sql($this); jak tutaj dodac kod z klasy sql } } else { throw new Exception("Niepoprawna wartosc podanych parametrow"); } } public function check_point(){ if($user_point < $this->eps_cat_point[$this->cat_point]){ return true; } else { return false; } } public function update_point(){ $this->query = "UPDATE tabela SET user_point=user_point+'".$this->eps_cat_point[$this->cat_point]."' WHERE user_id='".$this->user_id."'"; return $this->query; } public function delete_point(){ if($this->check_point()){ $this->query = "UPDATE tabela SET user_point=0 WHERE user_id='".$this->user_id."'"; return $this->query; } else { $this->query = "UPDATE tabela SET user_point=user_point-'".$this->eps_cat_point[$this->cat_point]."' WHERE user_id='".$this->user_id."'"; return $this->query; } } } $eps = new Eps(12, 'A', 'update_point');
.