Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64-bit integers are not supported by 32-bit builds of PHP at src/MysqlDataType.php:479 #135

Open
person004 opened this issue Nov 26, 2024 · 2 comments

Comments

@person004
Copy link

PHP 8.2 on 32-bit machine using DietPi(https://dietpi.com).

  1. I met following message when I used prepared statement($db->prepare). This did not happen when I used $db->query.
    server.error : '64-bit integers are not supported by 32-bit builds of PHP at src/MysqlDataType.php:479'

  2. I changed code like below at src/MysqlDataType.php

478 /*
479 if (\PHP_INT_SIZE <= 4) {
480 throw new \RuntimeException('64-bit integers are not supported by 32-bit builds of>
481 }
482 */
483
484 //$result = \unpack("P", $bytes, $offset)[1];
485 $result = \unpack("V", $bytes, $offset)[1];

the reason I changed from P to V.

V unsigned long (always 32 bit, little endian byte order)
P unsigned long long (always 64 bit, little endian byte order)

at https://www.php.net/manual/en/function.pack.php

It works well now, I can not propose something like pull request cause I do not know well about unpack function and amphp/mysql.

I just hope amphp/mysql supports 32-bit machine too!

@kelunik
Copy link
Member

kelunik commented Nov 27, 2024

We could support this more gracefully and support the 32 bit integer range PHP can represent, but I'm not sure it's worth the effort.

Why do you still use 32 bit? RPi zero?

@person004
Copy link
Author

@kelunik
First of all, thank you for your reply and the solution. I’m using a Raspberry Pi B+ (ARMv6, 512MB). The reason I’m using it is because it still works! PHP 8.1 doesn’t work well on my Pi with Raspbian (Raspberry Pi OS), but I was able to install PHP 8.2 thanks to DietPi, and it works great.

I’ve used Node.js on it, but the performance was really poor. I also have another, more powerful Pi where I use Java, but using PHP in a reactive way on my Pi B+ is great for me—it’s still running smoothly!

I think there are still many older Pi-like machines and other 32-bit devices. So, supporting 32-bit devices is not a bad decision. I believe DietPi, PHP, and AMPHP are great, especially since they still work well on the Raspberry Pi B+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants