>From perldoc DBIx::Recordset...
$set -> do ($statement, $attribs, \%params)
Same as DBI. Executes a single SQL statement on the open
database.
I implemented the process via regular DBI, since I couldn't figure it out w/
DBIx. I don't even think DBI->do would have done it for me, as I realized
that I needed data back. Here's the script -
#!/usr/bin/perl
use DBI;
my $LOGS = 2;
my $dbh = DBI->connect("DBI:mysql:database;host;port=3306", '', '');
my $sth = $dbh->prepare('show master logs');
$sth->execute();
my $row;
while ($row = $sth->fetchrow_arrayref)
{
push @logs, $row->[0];
}
my $log_amt = scalar(@logs);
print "$log_amt logs.\n";
if ($log_amt < $LOGS)
{
print "Not enough logs to purge. Must keep $LOGS logs.\n";
exit;
}
else
{
my $purge_to = $log_amt - $LOGS;
if (($log_amt - $purge_to) < $LOGS)
{
print "Not enough logs left after purge. Must keep $LOGS
logs.\n";
exit;
}
print "purging to $logs[$purge_to]\n";
$dbh->do("purge master logs to '$logs[$purge_to]'");
}
exit;
Someone implement that in DBIx::Recordset?
--
sh
-----Original Message-----
From: Terrence Brannon [mailto:[EMAIL PROTECTED]
Sent: Friday, October 08, 2004 12:23 PM
To: Steven Hajducko
Cc: '[EMAIL PROTECTED]'
Subject: Re: DBIx::Recordset 'do' syntax?
Steven Hajducko wrote:
> Having trouble using DBIx::Recordset->do.
I don't see a DBIx::Recordset->do() call in the docs... where did you see
that?
> I'd like to use the do command to
> issue 'show master logs' on a MySQL database.
perhaps you mean $dbh->do()
that is a pure DBI call. Recordset can return a DBI database handle to you
> I'm confused on how to use $set
> w/out actually specifiying a table to use.
http://search.cpan.org/author/TBONE/DBIx-Recordset-Playground-1.12/Playgroun
d.pm
shows how to do this for Recordset API calls.
>
> Could anyone write a simple example of how to use $set->do in such a way
> that you actually get rows of data back?
>
--
Terrence Brannon, [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]