Zebra_Database::fetch_assoc PHP Method

fetch_assoc() public method

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 }
public fetch_assoc ( resource $resource = '' ) : mixed
$resource resource (Optional) Resource to fetch. If not specified, the resource returned by the last run query is used. @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.
return mixed
    function fetch_assoc($resource = '')
    {
        // if an active connection exists
        if ($this->_connected()) {
            // if no resource was specified, and a query was run before, assign the last resource
            if ($resource == '' && isset($this->last_result)) {
                $resource =& $this->last_result;
            }
            // if $resource is a valid resource, fetch and return next row from the result set
            if ($this->_is_result($resource)) {
                return mysqli_fetch_assoc($resource);
            } elseif (is_integer($resource) && isset($this->cached_results[$resource])) {
                // get the current entry from the array and advance the pointer
                $result = each($this->cached_results[$resource]);
                // return as an associative array
                return @$result[1];
                // if $resource is invalid
            } else {
                // save debug information
                $this->_log('errors', array('message' => $this->language['not_a_valid_resource']));
            }
        }
        // we don't have to report any error as either the _connected() method already did
        // or did so the checking for valid resource
        return false;
    }