CI_DB_mysqli_driver::field_data PHP Method

field_data() public method

Returns an object with field data
public field_data ( string $table ) : array
$table string
return array
    public function field_data($table)
    {
        if (($query = $this->query('SHOW COLUMNS FROM ' . $this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) {
            return FALSE;
        }
        $query = $query->result_object();
        $retval = array();
        for ($i = 0, $c = count($query); $i < $c; $i++) {
            $retval[$i] = new stdClass();
            $retval[$i]->name = $query[$i]->Field;
            sscanf($query[$i]->Type, '%[a-z](%d)', $retval[$i]->type, $retval[$i]->max_length);
            $retval[$i]->default = $query[$i]->Default;
            $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
        }
        return $retval;
    }