php / php/pecl-database-pdo_ibm

garbage characters at the end of string

Open
#26 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
20
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Server: DB2 7.1.0
Client: 11.5.4.0
PHP: 8.2.17
pdo_ibm: latest main branch

There is no problem with the following command line:
db2 "SELECT ONAME from MYTABLE where ID='590'"

However, retrieving data via PHP like this:

$dbh = new PDO($dsn);
$result = $dbh->query("SELECT ONAME from MYTABLE where ID='590'");
foreach($result as $row){
    echo  $row[0];
}

At the end of the string, there is a 0x00 and some other random characters.

trim($row[0],"\x0")
can remove the trash characters.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown PHP PDO query against DB2 and compare its returned string with the command-line result. Start by tracing how pdo_ibm handles returned string values; done means the PHP result no longer contains the trailing 0x00 or random characters while preserving the actual value.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.