php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78227 Prepared statements ignore RENAME COLUMN
Submitted: 2019-06-28 10:32 UTC Modified: -
From: cmb@php.net Assigned:
Status: Open Package: PDO SQLite
PHP Version: 7.2.19 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-06-28 10:32 UTC] cmb@php.net
Description:
------------
As of SQLite 3.25.0, ALTER TABLE RENAME COLUMN queries are
supported.  However, already prepared statements ignore such
changes, and report the old column names when fetching.
ext/sqlite3 behaves like expected.


Test script:
---------------
<?php
$db = new PDO('sqlite::memory:');
$db->exec("CREATE TABLE user (id INTEGER PRIMARY KEY NOT NULL, foo VARCHAR(255) NOT NULL)");
$db->exec("INSERT INTO user (id, foo) VALUES (10, 'test')");
$stmt = $db->prepare("SELECT * FROM user WHERE id = :id");
$stmt->execute(['id' => 10]);
print_r($stmt->fetch(PDO::FETCH_ASSOC));
$db->exec("ALTER TABLE user RENAME COLUMN foo TO bar");
$res = $stmt->execute(['id' => 10]);
print_r($stmt->fetch(PDO::FETCH_ASSOC));


Expected result:
----------------
Array
(
    [id] => 10
    [foo] => test
)
Array
(
    [id] => 10
    [bar] => test
)

Actual result:
--------------
Array
(
    [id] => 10
    [foo] => test
)
Array
(
    [id] => 10
    [foo] => test
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 19:01:35 2019 UTC