
How to get field names of table in Codeigniter
Created at 23-May-2021 ,
By samar
How to get field names of table in Codeigniter
In this tutorial, we will try to find the solution to "How to get field names of table in Codeigniter" through programming.
You can get field (column) names of a table in Codeigniter using the getFieldNames() method which is used in Codeigniter 4. This method returns all the column names of the specified table in array form. You can also use the list_fields() method on the $this->db object to get the list of all columns of the table in codeigniter 3.-
Get column names of table in codeigniter 4
--PATH app\Controllers\<Home>.phppublic function getColumnNamesFromTable(){ $db = \Config\Database::connect(); $fields = $db->getFieldNames('heroes'); foreach ($fields as $field) { echo $field . "<br>"; } die(); }
-
Get column names of table in Codeigniter 3
$fields = $this->db->list_fields('heroes'); foreach ($fields as $field) { echo $field . "<br/>"; }
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: CodeIgniter
- Call to undefined function CodeIgniter\locale_set_default()
- Update an existing table record with +1 in CodeIgniter
- How to call helper function in Codeigniter view
- Get last executed query in codeigniter
- No input file specified Codeigniter
- Codeigniter 4 call model function from controller
- Unable to set session in codeigniter
- Convert dd/mm/yyyy to yyyy-mm-dd in codeigniter
- How to load a view in CodeIgniter?
- How to select all checkbox in Codeigniter
- How to move from one view to another in Codeigniter
- Default htaccess file code Codeigniter
- How to create custom helper in codeigniter 4
- Get the version codeIgniter