/** * Deletes data from Relational Map Table * * @param mixed $what */ public function delete($what = '') { if (func_num_args() > 1) { $what = Util::getParams(func_get_args()); } if ($this->schema) { $table = $this->schema . "." . $this->source; } else { $table = $this->source; } $conditions = ''; if (is_array($what)) { if ($what["conditions"]) { $conditions = $what["conditions"]; } } else { if (is_numeric($what)) { KumbiaActiveRecord::sql_sanitize($this->primary_key[0]); $conditions = "{$this->primary_key[0]} = '{$what}'"; } else { if ($what) { $conditions = $what; } else { KumbiaActiveRecord::sql_sanitize($this->primary_key[0]); $conditions = "{$this->primary_key[0]} = '{$this->{$this->primary_key[0]}}'"; } } } if (method_exists($this, "before_delete")) { if ($this->{$this->primary_key[0]}) { $this->find($this->{$this->primary_key[0]}); } if ($this->before_delete() == 'cancel') { return false; } } else { if (isset($this->before_delete)) { if ($this->{$this->primary_key[0]}) { $this->find($this->{$this->primary_key[0]}); } $method = $this->before_delete; if ($this->{$method}() == 'cancel') { return false; } } } $val = $this->db->delete($table, $conditions); if ($val) { if (method_exists($this, "after_delete")) { if ($this->after_delete() == 'cancel') { return false; } } else { if (isset($this->after_delete)) { $method = $this->after_delete; if ($this->{$method}() == 'cancel') { return false; } } } } return $val; }