php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48265 Source and result of database have different encodings.
Submitted: 2009-05-13 18:59 UTC Modified: 2012-03-31 05:52 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: rodsouza at celepar dot pr dot gov dot br Assigned: yohgaki (profile)
Status: Not a bug Package: PostgreSQL related
PHP Version: 6CVS-2009-05-13 (snap) OS: Debian Lenny
Private report: No CVE-ID: None
 [2009-05-13 18:59 UTC] rodsouza at celepar dot pr dot gov dot br
Description:
------------
When I try to access an array by a key that was created by 'pg_fetch_array' or 'PDOStatement::fetchAll' the result is 'NULL'.

Reproduce code:
---------------
$sql = "SELECT * from phpgw_config WHERE config_app='phpgwapi' and config_name='webserver_url'";

##
#Result
#
#Array
#(
#   [config_app] => phpgwapi
#   [config_name] => webserver_url
#   [config_value] => /expresso
#)
##

( $conn = pg_pconnect("dbname=expresso user=postgres") )
    or die( 'A error occured at line #' . __FILE__ . "\n" );
    
( $result = pg_query($conn, $sql ) )
    or die( 'A error occured at line #' . __FILE__ . "\n" );
    
$config = array( );

$config[ 'something' ] = array(
    'key_1' => 'anything',
    'key_2' => 'otherthing'
);  

$config[ 'server' ] = pg_fetch_array( $result, NULL, PGSQL_ASSOC );

var_dump( $config[ 'server' ][ 'config_name' ] );

try
{
    $pdo = new PDO('pgsql:dbname=expresso', 'postgres');
    
    $pdo_stmt = $pdo -> prepare( $sql );

    $pdo_stmt -> execute( );

    $config[ 'server' ] = $pdo_stmt -> fetch( PDO::FETCH_ASSOC );

    var_dump( $config[ 'server' ][ 'config_name' ] );
}
catch ( PDOException $e )
{
    echo 'PDO ERROR: ' . $e -> getMessage( );
}

Expected result:
----------------
webserver_url
webserver_url

Actual result:
--------------
NULL
NULL

-----

If:

var_dump( $config[ 'server' ][ b'config_name' ] );

The result is 'webserver_url'.

The problem is that I have a great application that have 1146 PHP files and it is impossible to search for all the places that need this change.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-31 05:52 UTC] yohgaki@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: yohgaki
 [2012-03-31 05:52 UTC] yohgaki@php.net
Returning NULL is perfectly ok.
You're asking debugging php code and database data.

If you are not, please describe what feature is broken. How it is broken.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC