Search code examples
codeigniterstructure

How to get table structure in CodeIgniter


I want to know the structure of a table. How I can do it in CodeIgniter. Using database class I got 'Invalid SQL Statement' error when I ran $this->db->query('desc mytable');


Solution

  • Try:

    $fields = $this->db->list_fields('table_name');
    foreach ($fields as $field)
    {
       echo $field;
    }
    

    From manual