do

do is used to perform non-SELECT SQL statements. It does the same thing as a $handle->prepare and a $handle->execute, except it does it all in one function call. The return value for do is the number of rows affected.

Examples:

my $sql_statement = qq(INSERT INTO kids VALUES ?, ?, ?); my @stuff =  qw(luc rae logan); my $rows = $handle->do($sql_statement, {}, @stuff);

This example inserts the names of my kids into the database table kids.

The first argument is the actual SQL statement. This can be a variable containing the statement, or it can be the actual text of the SQL statement. The second argument is a reference to a hash of attributes and is unused in MySQL. The third argument is an array that contains the data that will replace the placeholders (the “?"s) in the SQL statement.

Only the first argument is required; the others are optional.



Perl Database Programming
Perl Database Programming
ISBN: 0764549561
EAN: 2147483647
Year: 2001
Pages: 175

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net