#20510 [Opn->Csd]: All spaces on a right padded string getting chopped
| From: | nicos@php.net | Date: | Wed, 20 Nov 2002 01:38:44 +0000 |
| Subject: | #20510 [Opn->Csd]: All spaces on a right padded string getting chopped | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-25309@lists.php.net to get a copy of this message | ||
ID: 20510
Updated by: nicos@php.net
Reported By: jrust@php.net
-Status: Open
+Status: Closed
Bug Type: MySQL related
Operating System: Linux
PHP Version: 4.3.0RC1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-11-19 19:22:04] jrust@php.net
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