I\'ve hit one more bump in the road of migrating from the old mysql_*()
functions to the new PDO class:
I have a the following table:
CREATE TABLE `
I'd write small routine to patch the PDO output to suit the requirements, and try to make the least amout of changes to the coding.
$results = pdoFix($SqlResult->fetchAll(PDO::FETCH_BOTH))
function pdoFix($results) {
foreach ($results as &$row) { // note the "&"
$row[0] = sprintf("%'04s",$row[0]); // zerofill '0'
$row['id'] = sprintf("%'04s",$row['id']); // zerofill 'id'
}
unset($row); // break the reference with the last element
return $results;
}
Note: The other answers are just as good, pick one that you are most comfortable with.