public function fetch_assoc($resource = '') {

        // if no active connection exists, return false
        if (!$this->_connected()) return false;

        // if no resource was specified, and a query was run before, assign the last resource
        if ($resource == '' && isset($this->last_result) && $this->last_result !== false) $resource = & $this->last_result;

        // if $resource is a valid resource
        if ($this->_is_result($resource)) {

            // fetch next row from the result set
            $result = mysqli_fetch_assoc($resource);

            // if this was an unbuffered query manage setting the value for $returned_rows and some other things
            if ($resource->type == 1) $this->_manage_unbuffered_query_info($resource, $result);

            // return next row, or FALSE if no more rows available
            return $result;

        // if $resource is a pointer to an array taken from cache
        } elseif (is_integer($resource) && isset($this->cached_results[$resource])) {

            // get the current entry from the array
            $result = current($this->cached_results[$resource]);

            // advance the pointer
            next($this->cached_results[$resource]);

            // note that the above could've been done in a single step, using PHP's each() function
            // but it has been deprecated starting with PHP 7.2.0

            // return the value
            return $result;

        }

        // if $resource is invalid
        // save debug information
        return $this->_log('errors', array(

            'message'   => $this->language['not_a_valid_resource'],

        ));

    }
public function fetch_assoc($resource = '') {

        // if no active connection exists, return false
        if (!$this->_connected()) return false;

        // if no resource was specified, and a query was run before, assign the last resource
        if ($resource == '' && isset($this->last_result) && $this->last_result !== false) $resource = & $this->last_result;

        // if $resource is a valid resource
        if ($this->_is_result($resource)) {

            // fetch next row from the result set
            $result = mysqli_fetch_assoc($resource);

            // if this was an unbuffered query manage setting the value for $returned_rows and some other things
            if ($resource->type == 1) $this->_manage_unbuffered_query_info($resource, $result);

            // return next row, or FALSE if no more rows available
            return $result;

        // if $resource is a pointer to an array taken from cache
        } elseif (is_integer($resource) && isset($this->cached_results[$resource])) {

            // get the current entry from the array
            $result = current($this->cached_results[$resource]);

            // advance the pointer
            next($this->cached_results[$resource]);

            // note that the above could've been done in a single step, using PHP's each() function
            // but it has been deprecated starting with PHP 7.2.0

            // return the value
            return $result;

        }

        // if $resource is invalid
        // save debug information
        return $this->_log('errors', array(

            'message'   => $this->language['not_a_valid_resource'],

        ));

    }
public function fetch_assoc ( $ resource = '' ) { // if no active connection exists, return false if ( ! $ this -> _connected ( ) ) return false ; // if no resource was specified, and a query was run before, assign the last resource if ( $ resource == '' && isset ( $ this -> last_result ) && $ this -> last_result !== false ) $ resource = & $ this -> last_result ; // if $resource is a valid resource if ( $ this -> _is_result ( $ resource ) ) { // fetch next row from the result set $ result = mysqli_fetch_assoc ( $ resource ) ; // if this was an unbuffered query manage setting the value for $returned_rows and some other things if ( $ resource -> type == 1 ) $ this -> _manage_unbuffered_query_info ( $ resource , $ result ) ; // return next row, or FALSE if no more rows available return $ result ; // if $resource is a pointer to an array taken from cache } elseif ( is_integer ( $ resource ) && isset ( $ this -> cached_results [ $ resource ] ) ) { // get the current entry from the array $ result = current ( $ this -> cached_results [ $ resource ] ) ; // advance the pointer next ( $ this -> cached_results [ $ resource ] ) ; // note that the above could've been done in a single step, using PHP's each() function // but it has been deprecated starting with PHP 7.2.0 // return the value return $ result ; } // if $resource is invalid // save debug information return $ this -> _log ( 'errors' , array ( 'message' => $ this -> language [ 'not_a_valid_resource' ] , ) ) ; }
Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. The
data is taken from the resource created by the previous query or from the resource given as argument.

<code>
// run a query
$db->query('SELECT * FROM table WHERE criteria = ?', array($criteria));

// iterate through the found records
while ($row = $db->fetch_assoc()) {

// code goes here

}
</code>

@param  resource    $resource   (Optional) Resource to fetch.

<i>If not specified, the resource returned by the last run query is used.</i>

@return mixed                   Returns an associative array that corresponds to the fetched row and moves the
internal data pointer ahead, or FALSE if there are no more rows.
Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead . The data is taken from the resource created by the previous query or from the resource given as argument .