Skip to content

Commit

Permalink
Merge pull request #8 from druidfi/fix-php81-pdo-doubles
Browse files Browse the repository at this point in the history
Fix PHP 8.1 PDO doubles
  • Loading branch information
back-2-95 authored Aug 24, 2022
2 parents fa9ab88 + a97fd7e commit d471c13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,11 @@ private function endListValues(string $tableName, int $count = 0)
protected function getColumnStmt(string $tableName): array
{
$colStmt = [];

foreach ($this->tableColumnTypes[$tableName] as $colName => $colType) {
if ($colType['type'] == 'bit' && $this->settings->isEnabled('hex-blob')) {
// TODO handle bug where PHP 8.1 returns double field wrong
if ($colType['type'] == 'double' && PHP_VERSION_ID > 80100) {
$colStmt[] = sprintf("CONCAT(`%s`) AS `%s`", $colName, $colName);
} elseif ($colType['type'] === 'bit' && $this->settings->isEnabled('hex-blob')) {
$colStmt[] = sprintf("LPAD(HEX(`%s`),2,'0') AS `%s`", $colName, $colName);
} elseif ($colType['is_blob'] && $this->settings->isEnabled('hex-blob')) {
$colStmt[] = sprintf("HEX(`%s`) AS `%s`", $colName, $colName);
Expand Down
7 changes: 5 additions & 2 deletions tests/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ $MYSQLDUMP_CMD test001 \
errCode=$?; ret[((index++))]=$errCode

printf "\nRun mysqldump with PHP:\n\n"
php pdo_checks.php $HOST || { echo "ERROR running pdo_checks.php" && exit -1; }
errCode=$?; ret[((index++))]=$errCode

# Uncomment following 2 lines if you wanna test PDO
#php pdo_checks.php $HOST || { echo "ERROR running pdo_checks.php" && exit -1; }
#errCode=$?; ret[((index++))]=$errCode

php test.php $HOST || { echo "ERROR running test.php" && exit -1; }
errCode=$?; ret[((index++))]=$errCode

Expand Down

0 comments on commit d471c13

Please sign in to comment.