php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39612 closeCursor() does not allow SQLite 2 statement to resume
Submitted: 2006-11-24 07:39 UTC Modified: 2006-11-24 09:16 UTC
From: randy at rcs-comp dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
 [2006-11-24 07:39 UTC] randy at rcs-comp dot com
Description:
------------
The documentation for PDOStatement::closeCursor():

frees up the connection to the server so that other SQL statements may be issued, but leaves the statement in a state that enables it to be executed again.

When using PDO with a SQLite 3 connection, this works as intended.  However, when trying to resume with a SQLite 2 connection, fetch() returns FALSE.

Reproduce code:
---------------
http://www.rcs-comp.com/phpcode/simple_pdo_test2.php.txt

Expected result:
----------------
4 arrays of the first row of data:

>php simple_pdo_test2.php
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)

Actual result:
--------------
The last call to fetch() returns FALSE

>php simple_pdo_test2.php
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
Array
(
    [id] => 1
    [0] => 1
    [user] => user1
    [1] => user1
    [email] => user1@example.com
    [2] => user1@example.com
    [time] => 1164353530
    [3] => 1164353530
    [message] => this is my message 1
    [4] => this is my message 1
    [confirmed] => 0
    [5] => 0
)
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-24 09:16 UTC] tony2001@php.net
>leaves the statement in a state that enables it to be
>executed again.

"executed again", not "fetched again".

SQLite3 supports sqlite3_reset() method which resets the statement and for some reason it's still possible to fetch the results without re-executing the statement (I think it's wrong, though).
SQLite2 does not have such a method, so closeCursor() just fetches all the data from the statement and "leaves the statement in a state that enables it to be executed again".
Yes, you have to re-execute it again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 20:01:29 2024 UTC