I'm new to PostgreSQL, today I use php PDO to connect to Postgres and user var_dump print the results, it's astonishing that there are many redundant spaces in the char column of result set, my php code:
$sth = $this->db->prepare($sql);
$sth->execute($params);
$result = $st->fetch(PDO::FETCH_ASSOC);
var_dump($result);
The result like this:
array(4) {
["uid"]=>
int(1)
["first_name"]=>
string(32) "xiaobing "
["last_name"]=>
string(32) "zhang "
["user_email"]=>
string(32) "aa@gmail.com "
}
And I test how long does the column first_name
:
echo "column first_name lenth: " . strlen($result['first_name'])."\n";
The result is :
column `first_name` length: 32
Background: I am used to use MySQL. Recently, I converted to Postgres. I am surprised that char
columns have redundant spaces because MySQL is not like this. Does Postgres need to process the redundant spaces by application program? Maybe I'm wrong.