pear NumRows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Fritz

    pear NumRows

    Hello,

    i'm using pear (for the first time). the function "numRows" (Win XP
    SP2 , IIS, MS ACCESS) gives me always the value "-1" (= the
    ErrrorObject) - although the
    sqlResult contains data.
    I have to check the number of rows before I use the sqlResult. How do
    I get the numbers of rows?

    Something like this:
    -------------------------------------------------
    $intCounter=0;
    while($row = $objSQLResult->fetchRow())
    $intCounter++;
    -------------------------------------------------
    works fine, but when I want to use the sqlResult again,it seems to be
    empty.

    What can I do?

    Thank you,
    Robert
  • Marcin Dobrucki

    #2
    Re: pear NumRows

    Robert Fritz wrote:
    [color=blue]
    > i'm using pear (for the first time). the function "numRows" (Win XP
    > SP2 , IIS, MS ACCESS) gives me always the value "-1" (= the
    > ErrrorObject) - although the
    > sqlResult contains data.
    > I have to check the number of rows before I use the sqlResult. How do
    > I get the numbers of rows?
    >
    > Something like this:
    > -------------------------------------------------
    > $intCounter=0;
    > while($row = $objSQLResult->fetchRow())
    > $intCounter++;
    > -------------------------------------------------
    > works fine, but when I want to use the sqlResult again,it seems to be
    > empty.
    >
    > What can I do?[/color]

    PEAR is a repository. What are you actually using? The DB package?
    How are you using numRows()? It should be used something like this:

    $res =& db->query("selec t * from foo");
    $no_rows = $res->numRows();

    You might want to start adding error checks into your code, a la the:

    if (PEAR::isError( $res)) {
    die($res->getMessage() );
    }

    /Marcin

    Comment

    Working...