I have used official alpine php-image for different versions with pdo_mysql extension.
Set PDO::ATTR_EMULATE_PREPARES = false to get native db value.
It's return float(11.1) instead of float(11.11) and problem with only Alpine while working proper for buster php-image
Issue reported on alpine too : https://gitlab.alpinelinux.org/alpine/aports/issues/11072
RUN apk update --no-cache \
&& apk add --no-cache $PHPIZE_DEPS \
&& docker-php-ext-install pdo pdo_mysql
Docker up & Run php test file not returning proper native value for float datatype in Mysql
<?php
// DB configuration
$host = 'localhost';
$user = 'test';
$dbPass = 'test';
$dbname = 'test';
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// PDO connection and settings
$pdo = new PDO($dsn, $user, $dbPass);
// It's required otherwise return value in string instead of float
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
// Here amount is float(5,2) & Value = 11.11
$sql = 'SELECT id, amount FROM account WHERE id=1236';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo '<pre>';
var_dump($row['amount']); // It's return float(11.1) instead of float(11.11)
echo "\n";
echo '</pre>';
exit;
The php images consume the source from https://www.php.net/, so when Cogitri said to ask upstream he meant php upstream
Looking at php bug reports of the 8 that mention Alpine I don't see a related one. So I would file the issue there since there's nothing actionable for us as maintainers of the image when we just consume what upstream provides
@wglambert thank you a lot for the list of bugs, alpine disables lots of tests to pass, this could help to fix them
So the issue is just about a way to buildextension in original image.
If you need this native data types you should build --with-pdo-mysql=shared,mysqlnd according to https://www.php.net/manual/en/mysqlinfo.library.choosing.php
Most helpful comment
So the issue is just about a way to buildextension in original image.
If you need this native data types you should build
--with-pdo-mysql=shared,mysqlndaccording to https://www.php.net/manual/en/mysqlinfo.library.choosing.php