I want to know the structure of the table. How can I do this in CodeIgniter. Using the database class, I got the error "Invalid SQL Statement" when running $this->db->query('desc mytable');
$this->db->query('desc mytable');
Try:
$fields = $this->db->list_fields('table_name'); foreach ($fields as $field) { echo $field; }
From the manual
For more details you should use
$fields = $this->db->field_data('table_name');
You will get something like this foreach field in fields like stdClass
name = "id" type = "int" max_length = 11 default = null primary_key = 1
To get the table schema in a CodeIgniter query:
$query = $this->db->query('SHOW CREATE TABLE yourTableName'); $queryResultArray = $query->result_array(); print_r( $queryResultArray[0]['Create Table'] );
Source: https://habr.com/ru/post/895298/More articles:IPad Keyboard Height Change Notification - ipadQUERY speed with limit and millionth records - sqlGood links to use ARIA? - htmlSorting vector objects in C ++ - c ++Is there a way to leave an argument from the help using python argparse - pythonDjango ImportError - pythonResizing a wpf window programmatically in C # - c #How to check for a variable in codeigniter (php)? newb question - phpHow to avoid many database trips and a lot of irrelevant data? - optimizationSQL * Loader stuck after loading 4.2 billion records - sql-loaderAll Articles