php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44310 PDOStatement::exec() returns int(1) to any successful query.
Submitted: 2008-03-02 10:30 UTC Modified: 2008-03-02 15:30 UTC
From: osc at zoyo dot info Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.5 OS: Windowx XP x86 SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: osc at zoyo dot info
New email:
PHP Version: OS:

 

 [2008-03-02 10:30 UTC] osc at zoyo dot info
Description:
------------
PDOStatement::exec() returns int(1) to any successful query.

I have tried it with PDO drivers for postgresql packaged with PHP
version 5.2.5 on Windows XP, and version 5.1.4 on Linux.

The method returns number of affected records on Linux, but returns int(1) to any successful query on Windows.

PostgreSQL version is 8.2.6 for Win32.

Reproduce code:
---------------
<?php

/*
create table test( tm timestamp );
*/

try{

	$db = new PDO(PDOSTR,DBUSER,DBPASS);

	$insert1 = $db->exec('insert into test values( now() )');
	$insert2 = $db->exec("insert into test values( now()+interval '1 day' )");
	$update  = $db->exec("update test set tm=now() + interval '2 day'");
	$select = $db->exec('select * from test');
	$delete  = $db->exec('delete from test');

}catch(PDOException $e){
	echo $e->getMessage();
	exit;
}

?>
insert1: <?=$insert1?>
 insert2: <?=$insert2?>
 update : <?=$update?>
 select : <?=$select?>
 delete : <?=$delete?>

Expected result:
----------------
insert1: 1 insert2: 1 update : 2 select : 0 delete : 2

Actual result:
--------------
insert1: 1 insert2: 1 update : 1 select : 1 delete : 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-02 15:30 UTC] iliaa@php.net
Since the PDO code is identical for both Windows and Linux, I suspect 
that the problem lies with the PostgreSQL driver on windows.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 23:01:30 2024 UTC