php / php/php-src

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

Aperta
#13,587 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@SakiTakamachi ci sta già lavorando.

Dal 5/3/2024.

Bug Extension: sqlite3 Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.