Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Problems with GT::SQL::Table->delete

Quote Reply
Problems with GT::SQL::Table->delete
Hi, I have a table with combination primary key (tid, pid), I want to delete all records where tid = x how can I do this? Is there an easy way?

I have tried using a condition object but it failed:
$cond = GT::SQL::Condition->new('tid', '=', $tid);
doesn't work.

I have also tried select all pid where tid = $tid, looping through the results and calling delete on each iteration as follows:
$handle = $table->select( { tid => $tid }, ['pid'] );
while(my $row = $handle->fetchrow_hashref) {
$table->delete( { tid => $tid, pid => $row->{'pid'} } );
}

And it fails saying it cannot make a condition object. Besides this is not very efficient.

Does anyone have any ideas?

Thanks in advance, regards,
Tommy

Last edited by:

tommyfotak: Sep 26, 2002, 1:00 PM
Subject Author Views Date
Thread Problems with GT::SQL::Table->delete tommyfotak 1974 Sep 26, 2002, 12:58 PM
Thread Re: [tommyfotak] Problems with GT::SQL::Table->delete
yogi 1890 Sep 26, 2002, 1:25 PM
Post Re: [yogi] Problems with GT::SQL::Table->delete
tommyfotak 1867 Sep 27, 2002, 1:18 AM
Post Re: [tommyfotak] Problems with GT::SQL::Table->delete
Alex 1873 Sep 26, 2002, 2:18 PM