[eluser]gh0st[/eluser]
I'm trying to figure out a way of combining Active Record and the table meta data functionality.
Instead of doing:
Code:
foreach($query->result() as $row):
print $row->name;
print $row->title;
print $row->body;
// and so on for possibily lots of fields
endforeach;
I want to have the ability to do the listing automatically, especially when I am on listing pages in my admin section.
According to the docs, you can (not all DB's handle this) get meta data:
Quote:$fields = $this->db->field_data('table_name');
foreach ($fields as $field)
{
echo $field->name;
echo $field->type;
echo $field->max_length;
echo $field->primary_key;
}
But as you will notice there is no $field->value, which would contain the value stored at said field.
What I'd like is to combine the Active Record's table meta data with the actual value.
This will prove useful for when I am in my admin section and I want to build a quick table using the fields I have asked for in my query.
I've tried the following:
1. Loop through the meta data and my query array to find common array key's and then try to append a field->value to my array.
This doesn't work, also if the database is really big this loop would be very slow.
Any help on this would be great.