All pastes #908920 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-18 20:27 UTC
rendered paste body
my $sth = $dbh->prepare("
        SELECT
                c.clid AS who,
                c.dst AS what,
                (c.billsec/60) AS time,
                c.calldate AS calldate
        FROM
                cdr c
        WHERE
                (
                        c.src BETWEEN ? AND ?
                )
        AND
                c.dst LIKE '%*'
        AND
                (
                        c.calldate BETWEEN ? AND ?
                )  
        ORDER BY   
                src
");

$config->{fromday} = $config->{fromday} ? $config->{fromday} : strftime( '%Y-%m-%d 00:00:00', localtime );
$config->{today} = $config->{today} ? $config->{today} : strftime( '%Y-%m-%d %H:%M:%S', localtime );

$sth->execute( $config->{srcstart}, $config->{srcend}, $config->{fromday}, $config->{today} );

if ( $sth->rows < 1 ) {
        die "Failure!\n";
}

$sth->finish;


# I always get failure! Here is a sample query from MySQL CLI directly:

select clid,dst,(billsec/60),calldate as time from cdr where (src between 7000 and 7199) and dst like '%*' and (calldate between '2008-02-18 00:00:00' and now()) order by src;

This returns 50 rows