public function get_columns($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)) {

            $result = array();

            // iterate through all the columns
            while ($column_info = mysqli_fetch_field($resource))

                // add information to the array of results
                // converting it first to an associative array
                $result[$column_info->name] = get_object_vars($column_info);

            // return information
            return $result;

        // if $resource is a pointer to an array taken from cache
        // return information that was stored in the cached file
        } elseif (is_integer($resource) && isset($this->cached_results[$resource])) return $this->column_info;

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

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

        ));

    }
public function get_columns($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)) {

            $result = array();

            // iterate through all the columns
            while ($column_info = mysqli_fetch_field($resource))

                // add information to the array of results
                // converting it first to an associative array
                $result[$column_info->name] = get_object_vars($column_info);

            // return information
            return $result;

        // if $resource is a pointer to an array taken from cache
        // return information that was stored in the cached file
        } elseif (is_integer($resource) && isset($this->cached_results[$resource])) return $this->column_info;

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

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

        ));

    }
public function get_columns ( $ 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 ) ) { $ result = array ( ) ; // iterate through all the columns while ( $ column_info = mysqli_fetch_field ( $ resource ) ) // add information to the array of results // converting it first to an associative array $ result [ $ column_info -> name ] = get_object_vars ( $ column_info ) ; // return information return $ result ; // if $resource is a pointer to an array taken from cache // return information that was stored in the cached file } elseif ( is_integer ( $ resource ) && isset ( $ this -> cached_results [ $ resource ] ) ) return $ this -> column_info ; // if $resource is invalid // save debug information return $ this -> _log ( 'errors' , array ( 'message' => $ this -> language [ 'not_a_valid_resource' ] , ) ) ; }
Returns an array of associative arrays with information about the columns in the MySQL result associated with
the specified result identifier.

Each entry will have the column's name as key and, associated, an array with the following keys:

- name
- table
- def
- max_length
- not_null
- primary_key
- multiple_key
- unique_key
- numeric
- blob
- type
- unsigned
- zerofill

<code>
// run a query
$db->query('SELECT * FROM table');

// print information about the columns
print_r('<pre>');
print_r($db->get_columns());
</code>

@param  resource    $resource   (Optional) Resource to fetch columns information from.

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

@since  2.0

@return mixed                   Returns an associative array with information about the columns in the MySQL
result associated with the specified result identifier, or FALSE on error.
Returns an array of associative arrays with information about the columns in the MySQL result associated with the specified result identifier .