Example #1
0
 public function __construct(IDataProvider $driver = null)
 {
     parent::__construct($driver);
     if (!$this->ObjectExist()) {
         throw new DataProviderException(MSG_DATABASE_PROVIDER_OBJECT_ERROR, E_USER_ERROR);
     }
     $this->columns = parent::Columns($this->view);
     if (!$this->key) {
         $this->key = $this->columns[0];
     }
 }
Example #2
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 #3
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);
 }