php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51429 PDOStatement clears output buffer and exits script
Submitted: 2010-03-29 18:12 UTC Modified: 2010-03-30 11:10 UTC
From: yajodj at msn dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.3.2 OS: Apache/2.2.8 (Ubuntu) mod_python
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yajodj at msn dot com
New email:
PHP Version: OS:

 

 [2010-03-29 18:12 UTC] yajodj at msn dot com
Description:
------------
I have upgraded recently to PHP 5.3.2 from www.dotdeb.org.

My application is fully based on PDO. Before the upgrade everything worked fine, but after, when PDOStatement::execute() is called and there are binded values, the result is always a blank page in the browser.

Even if there's some output before that call, it will be flushed and nothing will be returned.

Also it exits the script without any error reporting.

Note:
Something that may be important: I also upgraded to MySQL 5.1.44-0.dotdeb.0, and I'm having another issue I still couldn't repair:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Anyway, I don't think it matters, because in the script below I'm connecting by TCP, so it should not be related to sockets...

Test script:
---------------
<?php

$driver = 'mysql';
$host = 'hostname';
$user = 'username';
$schema = 'schemaname';
$password = 'userpassword';
$driver_options = array(
	PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
);
$errors = PDO::ERRMODE_EXCEPTION;
$db = new PDO("$driver:host=$host;dbname=$schema", $user, $password, $driver_options);
$db->setAttribute(PDO::ATTR_ERRMODE, $errors);

// Part A: This script fails
$stmt = $db->prepare('SELECT * FROM detalles WHERE id < :id');

/* In the next line we are going to bind a value. This is what fails.
 * By the way, I tried using:
 *		$stmt->bindParam(':id', $a = 15);
 * Also by using:
 *		$stmt->execute(array(':id'=>15));
 * 
 * ... same result.
 */
$stmt->bindValue(':id', 15);

echo 'This is some output that will never see the light';

// exit; // If you uncomment this line, the above output will see the light.

$stmt->execute(); // Here script flushes the output buffer and exits with no errors.
// End of part A. Comment it to activate part B.

// Part B: This script works. The only difference is that we aren't binding anything
$stmt = $db->prepare('SELECT * FROM detalles');
echo 'This is some output that will go out with no problem';
$stmt->execute();
var_dump($stmt->fetch()); // Displays the first record of `detalles`

?>

Expected result:
----------------
I expect it to bind the values as always and keep on going... or at least trigger some error of any kind that gives me a clue of where am I failing... or even more, at least exiting the execution without clearing the previous output.

This is very weird...

Actual result:
--------------
Part A of the previous script ouputs nothing...

Part B outputs this:

This is some output that will go out with no problem<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b>
  'id' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'93'</font> <i>(length=2)</i>
  0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'93'</font> <i>(length=2)</i>

  'servicio' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'65'</font> <i>(length=2)</i>
  1 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'65'</font> <i>(length=2)</i>

  'azafata' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'3175'</font> <i>(length=4)</i>
  2 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'3175'</font> <i>(length=4)</i>

  'tipo' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'1'</font> <i>(length=1)</i>
</pre>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-29 18:16 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-03-29 18:16 UTC] rasmus@php.net
This is a support question, not a bug report.  Please go through appropriate 
support channels for that.  And note that if you are getting a mysqld.sock error, 
you aren't actually going through tcp so that is your first clue.
 [2010-03-30 08:57 UTC] yajodj at msn dot com
The socket problem doesn't appear in PHP but in another programs.

As you can see in the example, I'm connecting through TCP. No sockets involved here.

By the way, if it were a socket problem, part B wouldn't work either, and i suppose part A would throw some kind of error.

Anyway, I'll try downgrading MySQL and I'll let you know the results.
 [2010-03-30 11:10 UTC] yajodj at msn dot com
Well, I downgraded succesfully to MySQL 5.0.51a-3ubuntu5.5.
No socket errors anymore. Bug persists.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 21:01:28 2024 UTC