}
}
if ('count' == $action) {
    $sql = "SELECT count(v.id) from defined_value v, attribute a\n\t\tWHERE v.attribute_id = a.id \n\t\tAND\ta.collection_id = {$c->id}\n\t\t";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    $count = $sth->fetchColumn();
    print "defined: {$count}\n";
} elseif ('delete' == $action) {
    print "defined values\n";
    $sql = "SELECT v.id from defined_value v, attribute a\n\t\tWHERE v.attribute_id = a.id \n\t\tAND\ta.collection_id = {$c->id}\n\t\t";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    while ($id = $sth->fetchColumn()) {
        $defined = new Dase_DBO_DefinedValue($db);
        if ($defined->load($id)) {
            $defined->delete();
            print "deleted defined value\n";
        }
    }
}
if ('count' == $action) {
    $sql = "SELECT count(id) from attribute a\n\t\tWHERE a.collection_id = {$c->id}\n\t\t";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    $count = $sth->fetchColumn();
    print "attributes: {$count}\n";
} elseif ('delete' == $action) {
    print "attributes\n";
    $sql = "DELETE from attribute \n\t\tWHERE collection_id = {$c->id}\n\t\t";
    $count = $dbh->exec($sql);