|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-30 15:52 UTC] cmb@php.net
[2015-07-01 05:31 UTC] yohgaki@php.net
[2015-07-01 11:58 UTC] cmb@php.net
-Status: Open
+Status: Wont fix
[2015-07-01 14:42 UTC] buschmann at nidsa dot net
[2015-07-01 17:22 UTC] cmb@php.net
-Status: Wont fix
+Status: Open
[2016-05-02 17:10 UTC] ab@php.net
-Status: Open
+Status: Wont fix
[2016-05-02 17:10 UTC] ab@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 22:00:01 2025 UTC |
Description: ------------ /* ################# ERROR Results in PHP ############################## // the ERROR is that char strings retrieved by pg_fetch_assoc (or similar calls) always return the maximum length of the column // i.E when we select the fix string, the database always returns the correct length (pgflen) but php always gives 6 (phpflen)!!!! // for better illustration, in phpfixreplace all blanks returned are replaced with # // this has been tested with php 5.6.10 and php 7 alpha 2 and seems to be similar on other versions and platforms (not tested) // platform: windows 8.1 64 bit, Apache 64bit 2.4.12 VC14, php TS in 64 bit, // module extension=php_pgsql.dll below the output: v-- ERROR v-- ERROR cfix = pgfix = ## pgflen = 0 phpflen = 6 phpfix = [ ] phpfixreplace = [######] Test script: --------------- <?php $conexion=pg_connect('CONNECTION_STRING'); $sqlIns="select length(cfix) as pgflen, cfix, '#'||cfix||'#' as pgfix ,length(cvar) as pgvlen, cvar, '#'||cvar||'#' as pgvar from ctest"; $rS=pg_query($sqlIns); while($fs=pg_fetch_assoc($rS)){ echo "<table>"; echo "<tr><td> cfix = ".$fs['cfix']." pgfix = ".$fs['pgfix']." pgflen = ".$fs['pgflen']." phpflen = ".strlen($fs['cfix']). " phpfix = [".$fs['cfix']."] phpfixreplace = [".str_replace(' ','#',$fs['cfix'])."]</td></tr>" ; echo "<tr><td> cvar = ".$fs['cvar']." pgvar = ".$fs['pgvar']." pgvlen = ".$fs['pgvlen']." phpvlen = ".strlen($fs['cvar']). " phpvar = [".$fs['cvar']."] phpvarreplace = [".str_replace(' ','#',$fs['cvar'])."]</td></tr>"; ; echo "</table>"; } ?> Expected result: ---------------- /* // create the table and fill with test strings in Postgres create table ctest ( cfix char(6), cvar varchar (6) ); insert into ctest values ('',''), ('f2','v2'), ('f6f6f6','v6v6v6') ; // select in psql db=# select db-# length(cfix) as flen, cfix, '#'||cfix||'#' as pgfix db-# ,length(cvar) as vlen, cvar, '#'||cvar||'#' as pgvar db-# from ctest db-# ; flen | cfix | pgfix | vlen | cvar | pgvar ------+--------+----------+------+--------+---------- 0 | | ## | 0 | | ## 2 | f2 | #f2# | 2 | v2 | #v2# 6 | f6f6f6 | #f6f6f6# | 6 | v6v6v6 | #v6v6v6# (3 Zeilen) */ Actual result: -------------- below the output: v-- ERROR v-- ERROR cfix = pgfix = ## pgflen = 0 phpflen = 6 phpfix = [ ] phpfixreplace = [######] cvar = pgvar = ## pgvlen = 0 phpvlen = 0 phpvar = [] phpvarreplace = [] cfix = f2 pgfix = #f2# pgflen = 2 phpflen = 6 phpfix = [f2 ] phpfixreplace = [f2####] cvar = v2 pgvar = #v2# pgvlen = 2 phpvlen = 2 phpvar = [v2] phpvarreplace = [v2] cfix = f6f6f6 pgfix = #f6f6f6# pgflen = 6 phpflen = 6 phpfix = [f6f6f6] phpfixreplace = [f6f6f6] cvar = v6v6v6 pgvar = #v6v6v6# pgvlen = 6 phpvlen = 6 phpvar = [v6v6v6] phpvarreplace = [v6v6v6]