php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4087 Pg_NumRows() 1 when no data is stored.
Submitted: 2000-04-09 22:58 UTC Modified: 2005-03-31 16:13 UTC
From: uezaki at sra dot co dot jp Assigned:
Status: Wont fix Package: PostgreSQL related
PHP Version: 3.0.14 OS: AIX Version 4.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2000-04-09 22:58 UTC] uezaki at sra dot co dot jp
Please see attched PHP script sample.

When we try to get how many records have been already registered from
certain SQL table, usually we can get the correct result except if no record
has been registered yet. In that case, pg_NumRows returns 1 instead of 0.
I would like you to investigate this problem ASAP.

       // create SQL script
        $sql = "select dept_cd, sect_cd, employee_id from employee;
        $id = pg_Exec( $con, $sql );
        if ( !$id ) {
                echo "SQL cannot be executed!!" );
                exit;
        }

        // Get the number of rows
        $num=pg_NumRows( $id ) ;
        if ( !$num ) {
                echo "No record is registered!!" );
                exit;
        } else {
                echo( $num );
        }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-31 16:13 UTC] php-bugs at lists dot php dot net
We are sorry, but we do not support PHP 3 related problems anymore.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 02:01:23 2020 UTC