According to this page:
http://us3.php.net/manual/en/pdostatement.rowcount.php

Returning a row count for a SELECT statement is not consistently 
implemented across database drivers, and should not be depended upon. 
The method is meant to return a count of rows affected by an UPDATE, 
INSERT, or DELETE statement.

On 5/19/13 9:28 PM, Charles Curley wrote:
> I have an existing program in PHP. I just upgraded the
> server from Debian 6 to 7. In the process, that upgraded php from 5.3.3
> to 5.4.4. So far so good. But that means the old PHP interface to
> sqlite went away. So I'm trying to update from the old PHP sqlite
> interface to PDO.
>
> PDO is not acting like I would expect, or like some of the
> documentation indicates it should. The following code should return a
> row count. It does not; it consistently returns 0 even when there are
> multiple rows.
>
> --------------------------------------------------
>
> try {
>      ($dbh = new PDO("sqlite:$dbPath"));
> } catch (PDOException $exception) {
>      printf("Failed to connect to the  database. Error: %s",  
> $exception->getMessage());
>    }
>
> $query = "select rating, comment, categories from ratings where billType = 
> '$billType' and billNumber = '$billNumber'";
> print ("<p>$query</p>\n");
>
> $entry = $dbh->query($query);
>
> print "\nRetrieved " . $entry->rowCount() . " row(s).\n";
>
> --------------------------------------------------
>
> The query, stuffed with the variable names, works correctly in the
> sqlite3 command line tool.
>
> Thanks
>


/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to