On Mon, Feb 22, 2010 at 8:39 PM, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx>wrote: > On Mon, Feb 22, 2010 at 08:18:25PM -0700, Nathan Nobbe wrote: > > > On Mon, Feb 22, 2010 at 7:50 PM, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx> > wrote: > > > > Using MySQL 5.075, PHP 5.25 on Debian unstable. > > > > Has anyone noticed, when issuing a PDOStatement::rowCount() call > after a > > DELETE, UPDATE or INSERT, the return is uniformly zero, rather than > the > > actual number of rows affected? > > > > > > quick test shows rowCount() working in all 3 cases: > > > > <?php > > /** > > * lets test a PDOStatement::rowCount() bug > > * using an sqlite3 memory resident database > > */ > > Nifty, but you'll notice that I'm using MySQL, not SQLite3. And you > didn't mention which version PHP you're using. > it had occurred to me that you may be using a diff db and that could have something to do w/ it; however, ive just made a slight alteration to the script and its working np w/ mysql: ----------- sql ----------- mysql> create database TESTING; Query OK, 1 row affected (0.00 sec) mysql> use TESTING; Database changed mysql> CREATE TABLE TESTING ( -> id INT NOT NULL AUTO_INCREMENT, -> name CHAR(30) NOT NULL, -> PRIMARY KEY (id) -> ); ----------- php ----------- <?php /** * lets test a PDOStatement::rowCount() bug * using an sqlite3 database */ try { $oPdo = new PDO('mysql:host=192.168.56.101;dbname=TESTING', 'root', ''); $oStmt = $oPdo->query("INSERT INTO TESTING (name) VALUES ('nate dogg')"); echo 'Num rows inserted: ' . $oStmt->rowCount() . PHP_EOL; $oStmt = $oPdo->query("UPDATE TESTING SET name = 'snoop dog' WHERE id = 1"); echo "Num rows updated: " . $oStmt->rowCount() . PHP_EOL; $oStmt = $oPdo->query("DELETE FROM TESTING WHERE id = 1"); echo "Num rows deleted: " . $oStmt->rowCount() . PHP_EOL; } catch(Exception $oE) { die($oE->getMessage() . PHP_EOL); } ?> ------------ version ------------ php version: PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2 mysql version: Server version: 5.1.31-1ubuntu2 -nathan