January 2002
Intermediate to advanced
288 pages
8h 45m
English
sqlDo — executes an arbitrary SQL statement
my $rows = $slashdb->sqlDo($sql);
sqlDo prepares and executes an arbitrary SQL statement
in one fell swoop. It performs no processing or quoting, passing the contents
of $sql to the database verbatim. When an error occurs, it logs the
failed SQL statement and returns a false value. If the statement succeeds, it
returns the number of affected rows. Note that if the statement succeeds but
affected zero rows, the return value will be the special Perl value
0E0, which evaluates to “zero but true”. This
function can be used destructively. Be very careful, especially if anything in
$sql can come from outside of the Slash code itself.
# don't do this unless you really really mean it
my $rows = $slashdb->sqlDo("DROP DATABASE slash");
if ($rows) {
print "It was nice while it lasted.\n";
} else {
print "Dodged a bullet there!\n";
}Read now
Unlock full access