-----Original Message-----
From: Philip Mak
To: [EMAIL PROTECTED]
Sent: 06/26/2001 2:41 AM
Subject: Shorthand for $dbh->prepare and $sth->execute?

>I noticed that DBI now has some shortcut methods, e.g. selectrow_hashref
>which combines a prepare, execute and fetchrow in one function call.

>Is there a similar method to combine a prepare and execute?

Why?  You can prepare and execute with do() for update and insert
statements.

>$sth = $dbh->prepare("SELECT ...");
>$sth->execute;

e.g. something like:

$sth = $dbh->prepare_execute("SELECT ...");

>at which point I could do $sth->rows, $sth->fetchrow_hashref, etc.

$sth->rows does not guarantee and in most casese will not return the number
of rows that the select statement returns.  In most cases it will return the
rows fetched so far, or depending on the db driver the rows fetched in the
cache.  You should either use "select count(*) from ..." query to get the
number of rows or use a counter.

Ilya



-Philip Mak ([EMAIL PROTECTED])

Reply via email to