Again this depends on the database, so for writting portable code, I would
avoid this.
Have you ever tried selecting about a thousand or so rows?  I just wonder if
it still would work, since the db driver really can't know how many rows it
fetched until they are all fetched.  As I mentioned some drivers fetch so
many rows into a cache for better efficiency, but I don't know how
DBD::mysql does it since I rarelly use it, but I wonder if that's the case
for you.

Also you haven't convinced me that such a method, select_execute(), would be
helpful.  Why?  How would you use placeholders?  That's the real advantage
of select() and execute().


Ilya


-----Original Message-----
From: Philip Mak
To: Sterin, Ilya
Cc: '[EMAIL PROTECTED] '
Sent: 06/26/2001 8:18 AM
Subject: RE: Shorthand for $dbh->prepare and $sth->execute?

On Tue, 26 Jun 2001, Sterin, Ilya wrote:

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

What about SELECT statements, though? The selectrow_array functions
aren't
adequate for this, because they can only be used to return the first
row.

> $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.

I heard about this before, but it does not seem to be true for MySQL;
I've
never had trouble using $sth->rows under MySQL.

-Philip Mak ([EMAIL PROTECTED])

Reply via email to