PEAR:DB select problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernhard Hörlberger

    PEAR:DB select problem

    I have the following function. It checks if a User exists, authenticates
    that user based on the provided Password and Username, updates the last
    login info, and then returns a filepath to direct the user to.

    function login($aArgs) {

    if( !$this->_authenticate( $aArgs) ) {

    catchErr("Can't authenticate User");
    return FALSE;
    }

    $sql = " SELECT
    app.admin_app_p ath
    FROM
    ".PREFIX."_admi n_apps app,
    ".PREFIX."_admi n_perms perm
    WHERE
    app.admin_app_i d=perm.admin_ap p_id AND
    perm.admin_user _id=".$this->_iUserId." AND
    perm.admin_perm > 0
    ORDER BY
    app.admin_app_i d
    LIMIT 0, 1";

    if( DB::isError($sP ath = $this->_oConn->query($sql)) ) {

    catchExc($sPath->getMessage() );
    return FALSE;
    }

    if( empty($sPath) ) {

    catchErr("No acceptable application permissions");
    return FALSE;
    }

    $this->_updateLogin() ;
    return $sPath;
    }


    my problem is the following. the returned $sPath var doesn't contain the
    path, but merely a string saying "Object".
    any ideas on this?

    thanks a lot in advance,
    Bernhard


  • Jim Dabell

    #2
    Re: PEAR:DB select problem

    Bernhard Hrlberger wrote:

    [snip][color=blue]
    > if( DB::isError($sP ath = $this->_oConn->query($sql)) ) {[/color]
    [snip][color=blue]
    > my problem is the following. the returned $sPath var doesn't contain the
    > path, but merely a string saying "Object".[/color]

    query() returns a result set object:

    <URL:http://pear.php.net/manual/en/package.databas e.db.db-common.query.ph p>

    You then use this object to loop over the records returned by the select.
    It sounds like you want to use one of the shortcut functions, perhaps
    getOne()?

    if( DB::isError($sP ath = $this->_oConn->getOne($sql) ) ) {

    <URL:http://pear.php.net/manual/en/package.databas e.db.db-common.getone.p hp>


    --
    Jim Dabell

    Comment

    Working...