function fetchData($username, $password)
    {
        // Prepare for a database query
        $err = $this->_prepare();
        if ($err !== true) {
            return PEAR::raiseError($err->getMessage(), $err->getCode());
        }

        // Find if db_fields contains a *, i so assume all col are selected
        if(strstr($this->options['db_fields'], '*')){
            $sql_from = "*";
        }
        else{
            $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
        }

        $query = "SELECT ".$sql_from.
                " FROM ".$this->options['table'].
                " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username);

        $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
        $rset = $this->db->Execute( $query );
        $res = $rset->fetchRow();

        if (DB::isError($res)) {
            return PEAR::raiseError($res->getMessage(), $res->getCode());
        }
        if (!is_array($res)) {
            $this->activeUser = '';
            return false;
        }
        if ($this->verifyPassword(trim($password, "\r\n"),
                                  trim($res[$this->options['passwordcol']], "\r\n"),
                                  $this->options['cryptType'])) {
            // Store additional field values in the session
            foreach ($res as $key => $value) {
                if ($key == $this->options['passwordcol'] ||
                    $key == $this->options['usernamecol']) {
                    continue;
                }
                // Use reference to the auth object if exists
                // This is because the auth session variable can change so a static call to setAuthData does not make sence
                if(is_object($this->_auth_obj)){
                    $this->_auth_obj->setAuthData($key, $value);
                } else {
                    Auth::setAuthData($key, $value);
                }
            }

            return true;
        }

        $this->activeUser = $res[$this->options['usernamecol']];
        return false;
    }
function fetchData($username, $password)
    {
        // Prepare for a database query
        $err = $this->_prepare();
        if ($err !== true) {
            return PEAR::raiseError($err->getMessage(), $err->getCode());
        }

        // Find if db_fields contains a *, i so assume all col are selected
        if(strstr($this->options['db_fields'], '*')){
            $sql_from = "*";
        }
        else{
            $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
        }

        $query = "SELECT ".$sql_from.
                " FROM ".$this->options['table'].
                " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username);

        $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
        $rset = $this->db->Execute( $query );
        $res = $rset->fetchRow();

        if (DB::isError($res)) {
            return PEAR::raiseError($res->getMessage(), $res->getCode());
        }
        if (!is_array($res)) {
            $this->activeUser = '';
            return false;
        }
        if ($this->verifyPassword(trim($password, "\r\n"),
                                  trim($res[$this->options['passwordcol']], "\r\n"),
                                  $this->options['cryptType'])) {
            // Store additional field values in the session
            foreach ($res as $key => $value) {
                if ($key == $this->options['passwordcol'] ||
                    $key == $this->options['usernamecol']) {
                    continue;
                }
                // Use reference to the auth object if exists
                // This is because the auth session variable can change so a static call to setAuthData does not make sence
                if(is_object($this->_auth_obj)){
                    $this->_auth_obj->setAuthData($key, $value);
                } else {
                    Auth::setAuthData($key, $value);
                }
            }

            return true;
        }

        $this->activeUser = $res[$this->options['usernamecol']];
        return false;
    }
function fetchData ( $ username , $ password ) { // Prepare for a database query $ err = $ this -> _prepare ( ) ; if ( $ err !== true ) { return PEAR :: raiseError ( $ err -> getMessage ( ) , $ err -> getCode ( ) ) ; } // Find if db_fields contains a *, i so assume all col are selected if ( strstr ( $ this -> options [ 'db_fields' ] , '*' ) ) { $ sql_from = "*" ; } else { $ sql_from = $ this -> options [ 'usernamecol' ] . ", " . $ this -> options [ 'passwordcol' ] . $ this -> options [ 'db_fields' ] ; } $ query = "SELECT " . $ sql_from . " FROM " . $ this -> options [ 'table' ] . " WHERE " . $ this -> options [ 'usernamecol' ] . " = " . $ this -> db -> Quote ( $ username ) ; $ ADODB_FETCH_MODE = ADODB_FETCH_ASSOC ; $ rset = $ this -> db -> Execute ( $ query ) ; $ res = $ rset -> fetchRow ( ) ; if ( DB :: isError ( $ res ) ) { return PEAR :: raiseError ( $ res -> getMessage ( ) , $ res -> getCode ( ) ) ; } if ( ! is_array ( $ res ) ) { $ this -> activeUser = '' ; return false ; } if ( $ this -> verifyPassword ( trim ( $ password , "\r\n" ) , trim ( $ res [ $ this -> options [ 'passwordcol' ] ] , "\r\n" ) , $ this -> options [ 'cryptType' ] ) ) { // Store additional field values in the session foreach ( $ res as $ key => $ value ) { if ( $ key == $ this -> options [ 'passwordcol' ] || $ key == $ this -> options [ 'usernamecol' ] ) { continue ; } // Use reference to the auth object if exists // This is because the auth session variable can change so a static call to setAuthData does not make sence if ( is_object ( $ this -> _auth_obj ) ) { $ this -> _auth_obj -> setAuthData ( $ key , $ value ) ; } else { Auth :: setAuthData ( $ key , $ value ) ; } } return true ; } $ this -> activeUser = $ res [ $ this -> options [ 'usernamecol' ] ] ; return false ; }
Get user information from database

This function uses the given username to fetch
the corresponding login data from the database
table. If an account that matches the passed username
and password is found, the function returns true.
Otherwise it returns false.

@param   string Username
@param   string Password
@return  mixed  Error object or boolean
Get user information from database