Edit report at https://bugs.php.net/bug.php?id=63916&edit=1
ID: 63916 Updated by: google...@php.net Reported by: google...@php.net Summary: PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite Status: Open Type: Bug Package: PDO related PHP Version: 5.4.10 Block user comment: N Private report: N New Comment: Because we're currently running 3 branches I've sent the PR for this to master and I'm asking for it to be merged into 5.3.NEXT, 5.4.NEXT, and 5.5.NEXT respectively to maintain consistency. https://github.com/php/php-src/pull/253/ Previous Comments: ------------------------------------------------------------------------ [2013-01-06 05:20:07] google...@php.net Description: ------------ Binding a PDO parameter with pdo_sqlite on 64bit builds with PDO::PARAM_INT forces the param to be cast internally to an int. This means 64bit ints will be cast down to 32bit ints internally even if PHP was compiled against a 64bit arch. Test script: --------------- $num = 100004313234244; // notice this exceeds 32 bits $conn = new PDO('sqlite::memory:'); $conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); $stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); $stmt->bindValue(':id', 1, PDO::PARAM_INT); $stmt->bindValue(':num', $num, PDO::PARAM_INT); $stmt->execute(); $stmt = $conn->query('SELECT num FROM users'); $result = $stmt->fetchAll(PDO::FETCH_COLUMN); printf("Expected: %d Received: %d\n", $num, $result[0]); Expected result: ---------------- // expected to output Expected: 100004313234244 Received: 100004313234244 Actual result: -------------- // instead we get output of Expected: 100004313234244 Received: 294714180 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63916&edit=1