Welcome Guest, Not a member yet? Register   Sign In
Is there a way to get more metadata
#1

according to documentation the only metadata we can get with this "$fields = $this->db->field_data('table_name');"
are $field->name; $field->type;$field->max_length;$field->primary_key; but is there a way to check if a field is required or a foreign key?

thanks
Reply
#2

This might help

It is for mySQL, so you may need to implement something else to make it work for your database.
Reply
#3

(03-08-2018, 01:20 AM)javiecholson188 Wrote: according to documentation the only metadata we can get with this "$fields = $this->db->field_data('table_name');"
are $field->name; $field->type;$field->max_length;$field->primary_key; but is there a way to check if a field is required or a foreign key?

thanks

Yes, it will basically boil down to a manual parse of your RDBMS's "SHOW CREATE TABLE" return. And, as Kaosweaver mentions, the format here will depend on the database vendor. 

For cases where the table structure is more_or_less known, you could consider supplementing CI's metadata return with some hardcoded additions :-\
Reply




Theme © iAndrew 2016 - Forum software by © MyBB