php / php/php-src

SQLite3Result::fetchArray runs the query again. [O: Bug #64531 ]

Đang mở
#13,587 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

@SakiTakamachi đang làm issue này rồi.

Từ ngày 5/3/2024.

Bug Extension: sqlite3 Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.2k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

Already reported 11 years ago. Here: https://bugs.php.net/bug.php?id=64531

The following code:

<?php

$conn = new SQLite3('Log.sqlite', \SQLITE3_OPEN_READWRITE);

$res = $conn->query('CREATE TABLE myTable (id INTEGER PRIMARY KEY AUTOINCREMENT, a INTEGER, b INTEGER, c INTEGER)');
//$res = $conn->query('DELETE FROM myTable');

$res = $conn->query('INSERT INTO myTable VALUES (null, 1, 2, 3)'); // Inserts a row here (the null is an auto-incrementing PK).

$res->fetchArray(); // Inserts the *same* row data as above, again (with the next auto-incrementing PK number).
$res->fetchArray(); // And yet again...
$res = $conn->query('SELECT COUNT(id) FROM myTable');
$data = $res->fetchArray();

var_dump($data[0]);

Resulted in this output:

int(3)

But I expected this output instead:

int(1)
PHP Version

PHP 8.2

Operating System

Debian

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.