/**
     * Deletes this object from the database
     */
    protected function deleteInternal()
    {
        if ($this->instance === null) {
            parent::deleteInternal();
        }
        if ($this->table === null || $this->id_field === null) {
            return;
        }
        $id_field = new SwatDBField($this->id_field, 'integer');
        if (!property_exists($this, $id_field->name)) {
            return;
        }
        $id_ref = $id_field->name;
        $id = $this->{$id_ref};
        $instance_id = $this->instance === null ? null : $this->instance->id;
        if ($id !== null) {
            $sql = sprintf('delete from %s
				where %s = %s and instance %s %s', $this->table, $id_field->name, $id, SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
            SwatDB::exec($this->db, $sql);
        }
    }
Exemple #2
0
 /**
  * Deletes this object from the database
  */
 protected function deleteInternal()
 {
     $filename = $this->getFilePath();
     if ($this->image !== null) {
         $this->image->setFileBase($this->getFileBase());
         $this->image->delete();
     }
     parent::deleteInternal();
     if (file_exists($filename)) {
         unlink($filename);
     }
 }