public function destroy() { $this->deleted = true; if (!$this->id) { return; } $id = mysql_real_escape_string($this->id); $count = PaymentTransaction::count("paymentgateways.id = '{$id}'"); if ($count > 0) { throw new Excpetion('Unable to delete payment gateway, there are transactions that are using it'); } mysql_query("UPDATE `paymentgateways` SET `deleted` = true WHERE `id` = '{$id}' LIMIT 1;"); }