ID:               35793
 Updated by:       [EMAIL PROTECTED]
 Reported By:      deadman_great at mail dot ru
-Status:           Open
+Status:           Feedback
 Bug Type:         PDO related
 Operating System: RH Fedora Core 2
 PHP Version:      5.1.1
 New Comment:

Please remove all the unnecessary OO stuff and provide the table
structure (apparently I need it to run your code).


Previous Comments:
------------------------------------------------------------------------

[2005-12-24 17:06:49] deadman_great at mail dot ru

Sorry for mistaked code. Original code too long. I can write another
quick sample:

<?

class DB
{
        function __construct ()
        {
                $this->pdo = new
PDO('mysql:host=localhost;dbname=mydb','login','pass');
                
$this->pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
        }
        
        function Query ()
        {
                $query = 'SELECT `created`, to_days(from_unixtime(`created`)) as
`day`,count(`id`) as `count` '.
                'FROM `orders` '.
                'WHERE `partner`=:partner '.
                'AND `created`>=:date '.
                'GROUP BY `day`';

                $vars = array(':partner'=>9,':date'=>1132797644);

                $stm = $this->pdo->Prepare($query);
                $stm->Execute($vars);
                return $stm;
        }
}

$db = new DB();

// this fetch works
$result = $db->Query();
foreach ($result as $day)
{
        print_r($day); echo '<hr>';
}

// but this - throw error "General error: 2050"
$result = $db->Query();
foreach ($result as $day)
{
        print_r($day); echo '<hr>';
}

// this also throw same error
$result = $db->Query();
foreach ($result as $day)
{
        print_r($day); echo '<hr>';
}

?>

Given result:

Array ( [created] => 1134531133 [0] => 1134531133 [day] => 732659 [1]
=> 732659 [count] => 3 [2] => 3 ) 
Array ( [created] => 1134711133 [0] => 1134711133 [day] => 732661 [1]
=> 732661 [count] => 1 [2] => 1 ) 
Array ( [created] => 1134811133 [0] => 1134811133 [day] => 732662 [1]
=> 732662 [count] => 1 [2] => 1 ) 
Array ( [created] => 1134911133 [0] => 1134911133 [day] => 732663 [1]
=> 732663 [count] => 1 [2] => 1 ) 

Warning: main() [function.main]: SQLSTATE[HY000]: General error: 2050
in /home/test/pages/pdobug.php on line 37

Warning: main() [function.main]: SQLSTATE[HY000]: General error: 2050
in /home/test/pages/pdobug.php on line 43

------------------------------------------------------------------------

[2005-12-24 14:31:05] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



------------------------------------------------------------------------

[2005-12-24 03:15:35] deadman_great at mail dot ru

Description:
------------
Current script works fine on localhost (winxp), and throw errors on
remote server (rh-fedora).

Software:
Local: winxp-sp2,php-5.1.1,mysql-5.0.3
Remote: fedora-c2,php-5.1.1,mysql-5.0.9

Reproduce code:
---------------
$query = 'SELECT `created`, to_days(from_unixtime(`created`)) as
`day`,count(`id`) as `count` FROM `orders` WHERE `partner`=:partner AND
`created`>=:date GROUP BY `day`';

$vars = array(':partner'=>9,':date'=>1132797644);

$stm = $pdo->Prepare($query);
$result = $stm->Execute($vars);
foreach ($result as $day) // LINE-123
{
...
}

Expected result:
----------------
Rows.

Actual result:
--------------
Warning: main() [function.main]: SQLSTATE[HY000]: General error: 2050
in ... on line 123


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35793&edit=1

Reply via email to