Example #1
0
 public function Delete($key_value = false)
 {
     $key_value = $key_value ?: $this->{$this->key};
     $h = parent::Delete($this->table, "{$this->key} = " . $this->Escape($key_value));
     return $this->Rows($h) > 0;
 }
Example #2
0
 public function Delete($table = false, $condition = false, $cascade = array())
 {
     $table = $table ?: $this->table['name'];
     if (!empty($cascade)) {
         $to_delete = array();
         $condition = $condition ?: "1=1";
         $sql = "select {$this->key} from {$table} where {$condition}";
         $h = $this->Select($sql);
         if ($this->Rows($h) > 0) {
             while ($row = $this->FetchArray($h)) {
                 //$to_delete[] = $row[$this->key];
                 foreach ($cascade as $tab => $key) {
                     $sql = "delete from {$tab} where {$key}={$row[$this->key]}";
                     $this->Select($sql);
                 }
             }
         }
     }
     return parent::Delete($table, $condition);
 }