ID: 20510 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Linux PHP Version: 4.3.0RC1 New Comment:
Read the 2nd paragraph on: http://www.mysql.com/doc/en/CHAR.html "When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed. " Not a bug -> bogus Previous Comments: ------------------------------------------------------------------------ [2002-11-19 20:27:01] [EMAIL PROTECTED] <Zeev> it *seems* like a MySQL issue, but it could be some obscure PHP issue. Lets see. C API should be tested with MySQL 3 and MySQL4. Same for the PHP extension. I will do some tests and give feedbacks. ------------------------------------------------------------------------ [2002-11-19 20:07:13] [EMAIL PROTECTED] I never said it's not a bug. It is, the fact is that it's not PHP related but MySQL related, so bugs mysql.com ------------------------------------------------------------------------ [2002-11-19 20:02:09] [EMAIL PROTECTED] The posted details make it sound like a bug to me so unless you truly know the answer nicos I don't think this should be closed. jrust, maybe it'd be helpful if you provide a small db schema that'll go along with a query so others can easily test it. ------------------------------------------------------------------------ [2002-11-19 19:38:43] [EMAIL PROTECTED] I really don't think that can be PHP related... Post a MySQL bug instead? Did you tried that with MySQL 4 (C API)? Anyway if someone feels that I'm wrong, open it again. Thank you for the report. ------------------------------------------------------------------------ [2002-11-19 19:22:04] [EMAIL PROTECTED] The following mysql query should return the data padded with spaces on the right: <?php $query = ' SELECT RPAD(t1.f_field1,15,\' \'), RPAD(t2.f_field2, 15, \' \') FROM test.table1 as t1 LEFT JOIN test.table2 AS t2 ON t1.record=t2.joinID ORDER BY t1.record DESC'; $link = mysql_connect('localhost', 'root', 'password'); $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { var_dump($row); } ?> However, the all spaces to the right of the string are chopped off, as if PHP (or maybe the MySQL api?) is doing an rtrim on the data. Some details: * The exact same query run from the MySQL console returns the correctly padded data. * If the ORDER BY is commented out the data comes back padded correctly. * If the query does not contain a JOIN the data comes back padded correctly (even if there is an ORDER BY) * It doesn't matter what the data is for table1 and table2 so long as the two tables can be joined and have some data in the fields * I am using MySQL version 3.23.52 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20510&edit=1
