Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113295 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28763 invoked from network); 27 Feb 2021 12:34:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Feb 2021 12:34:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4E04E1804F2 for ; Sat, 27 Feb 2021 04:24:23 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 27 Feb 2021 04:24:22 -0800 (PST) Received: by mail-ot1-f52.google.com with SMTP id s3so11776656otg.5 for ; Sat, 27 Feb 2021 04:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NuNGoyS/PWPh/CrWXviYInJYAc4A/uCqJ/vS27A04fo=; b=Ra4D+moWMKzXTEb9pY6qD9nVKEqxkZGRUmOGbzVL0X4eks+bRqpdIcru5btHkr6lwi nucUuPG/S3Yw2WsWF6S23jaGYOS07louZH3nLnx6xMTF22ucaGWl0iEoFW6pDhOJFMmu UefJeEv25jzCN55ulrgj4kYz+rTBhxq6C28amA/bTRprSPo3MlNQD6xX9cmA/kJtEGfM cvhHEvbVk1c2oeR48wSVBolqKl16t1I5wvu76m0+GiqnWLE36VP1MGM4okyg9m//avax d9/E3zwXnQcDb/zIFiYFb2UlFnGYVA2jv2jbmNQi1L2rCVy9YrVf6j3xFUFhVliRGVaZ nFAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NuNGoyS/PWPh/CrWXviYInJYAc4A/uCqJ/vS27A04fo=; b=Y5kCz8a9vTQN1arslPjxMbtfvOejVhFOxnTtwroYULBIfyl5B5Nlq8lT+mP1jOwdoD JiQk5K8LOW+vUrsx2QWYKMduud8b+KdujcruzdskRnR+5IzHWBmgin7palBFzm9icwlb /C/9esx/kwXQ6+AsA8W2Tmkm8ZBOpXIVcer6r0ULux9qRtcHynkBEIGlh10W/9wFNDkM xsmO6sFEvgM2t9B9Qhs9scatvhnpx51nWt/RxgZnZYJm9kP36DueW+AUAfep0mYiQdr0 R5B30SXG8F51l/OGKLZhTvGA29EJDH5qgrTFWUla+UEukQaL82OXO4hunJO9E8koiwQK Sq7A== X-Gm-Message-State: AOAM531Awie2E+weJgmnC2PIYH7ci64MX5XeJxUJ0sqtetHMhIaLpigq UyUpmWnxJ3EEV+jkWk38UsU8i+KokDV8cSGHYgQa7RLHpipSeA== X-Google-Smtp-Source: ABdhPJzOc6uAjuT+YUNF7xf47Hv8wopR3A+VCVRmaXzlQTIDdRHEsbarZdW1MT3pU2pPbWEIQsBV7XnOrEMCqA5zhaY= X-Received: by 2002:a9d:6381:: with SMTP id w1mr6073260otk.236.1614428660541; Sat, 27 Feb 2021 04:24:20 -0800 (PST) MIME-Version: 1.0 References: <499c2591-fb11-1b9d-d402-39f7ec1c6b85@themad.com.au> In-Reply-To: <499c2591-fb11-1b9d-d402-39f7ec1c6b85@themad.com.au> Date: Sat, 27 Feb 2021 12:24:10 +0000 Message-ID: To: Matty The Mad Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000d3ae1505bc50763f" Subject: Re: [PHP-DEV] PDO integer changes in 8.1 will stop many websites I support From: davidgebler@gmail.com (David Gebler) --000000000000d3ae1505bc50763f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Matthew, 1. PHP 8 has not introduced a change to PDO_MYSQL in respect of how values are fetched. What makes the difference as to whether you get MySQL INT values fetched as strings or integers is whether you are running PHP with the mysqlnd https://dev.mysql.com/downloads/connector/php-mysqlnd/ and emulation mode is off. 2. ZEROFILL in MySQL does not change how integers are stored, only how they are displayed by MySQL clients. 00123 as a INT(5) ZEROFILL is still stored as integer 123. 3. ZEROFILL is deprecated in MySQL 8. MySQL documentation advises "consider using an alternative means of producing the effect of these attributes. For example, applications can use the LPAD() function to zero-pad numbers up to the desired width, or they can store the formatted numbers in CHAR columns.= " 4. Storing phone numbers and postal codes as integers is asking for trouble, they are types of data which are fundamentally better represented in storage as character types. 5. If you really need ints converted to string, turn on PDO::ATTR_STRINGIFY_FETCHES. Hope this helps. Dave On Sat, Feb 27, 2021 at 8:49 AM Matty The Mad wrote: > PHP 8.1 PDO has been changed so that when MySQL returns an integer it > will no longer be returned as a string, but as an int. > > The problem is this breaks any sites that use UNSIGNED ZEROFILL integer > fields in MySQL. > > I support a number of websites where the phone numbers and post codes > are all UNSIGNED ZEROFILL. > > The post codes in MySQL are stored as 0800. > > In PHP 8.0 returned as string 0800 > In PHP 8.1 returned as integer 800 > > 8.0.2 > string(10) "0742000000" > > 8.1.0-dev > int(742000000) > > PDO shouldn't really be changing the data. > > I propose that: > =E2=80=A2 any ZEROFILL integers are returned as string [or] > =E2=80=A2 there's an option to control this when making the connection (I= don't > want to str_pad() at every place I've used ZEROFILL in the past) [or] > =E2=80=A2 this backwards compatibility breaking change is removed until P= HP 9. > > Matthew Asia > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000d3ae1505bc50763f--