Created
December 18, 2008 19:05
-
-
Save markpasc/37599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
package CountEntries; | |
use strict; | |
use lib qw( extlib lib ); | |
use base qw( MT::Tool ); | |
sub help { q{} } | |
sub usage { q{} } | |
sub main { | |
my $class = shift; | |
my ($verbose) = $class->SUPER::main(@_); | |
print count(MT->model('entry'), {}, {}), "\n"; | |
} | |
sub count { | |
my ($class, $terms, $args) = @_; | |
my $driver = $class->driver; | |
my $stmt = $driver->prepare_statement($class, $terms, $args); | |
# Replace what search() would select with a COUNT(*). | |
$stmt->select([]); | |
$stmt->select_map({}); | |
$stmt->select_map_reverse({}); | |
$stmt->add_select('COUNT(*)'); | |
return $driver->select_one( $stmt->as_sql() ); | |
} | |
__PACKAGE__->main() unless caller; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment