php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31105 sqlite_single_query with "or die" does die when the return value is 0
Submitted: 2004-12-16 00:41 UTC Modified: 2004-12-16 01:15 UTC
From: dengode at gmail dot com Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dengode at gmail dot com
New email:
PHP Version: OS:

 

 [2004-12-16 00:41 UTC] dengode at gmail dot com
Description:
------------
When using sqlite_single_query and the return value from the query is 0 (zero) it's handled as if the query failed.

The code will not output 0, but instead die with the following message: "not an error"

The value of $result is set to 0, which is expected.

Reproduce code:
---------------
<?php
$db = sqlite_open("test.db");
sqlite_query($db, "CREATE TABLE Test ( number NUMERIC )");
sqlite_query($db, "INSERT INTO Test (number) VALUES (0)");

$result = @sqlite_single_query($db, "SELECT number FROM Test")
 or die(sqlite_error_string(sqlite_last_error($db)));

echo $result;
?>

Expected result:
----------------
A return value of 0 from the database being returned to $result without an exception.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-16 01:15 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Unlike regular query execution function single_query returns a value and not a resource. Since a valid resource can never be 0, doing "or die()" is safe, this is not the case when the result can be 0 value.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC