pg_query returns no rows - how to detect?

Discussion in 'PHP' started by Stu--, Jul 1, 2009.

  1. #1
    When querying a postgre db, anyone know how to deal with it when zero rows are returned?

    resource: pg_query ([ resource $connection ], string $query )

    As someone here http://se2.php.net/function.pg-query pointed out,

    "pg_query returns FALSE if the query can not be executed for some reason. If the query is executed but returns zero rows then you get back a result with no rows." - It does not return false when there are zero rows, so how do I catch it?

    Thanks and regards.
     
    Stu--, Jul 1, 2009 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is there an equivalent of mysql_num_rows? :)
     
    Wrighty, Jul 1, 2009 IP
  3. JDevereux

    JDevereux Peon

    Messages:
    50
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    use pg_num_rows to check how many rows are in the result.
     
    JDevereux, Jul 1, 2009 IP
  4. Stu--

    Stu-- Active Member

    Messages:
    355
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    53
    #4
    That's got it, thanks guys.
     
    Stu--, Jul 1, 2009 IP