Is it possible to fetch the names of the fields a table has, using Datamapper with Codeigniter?
I need to fetch the fields from a table so I can check if that particular table will accept a key/value pair. Is it possible to fetch only the field names? I'm using Datamapper with Codeigniter.开发者_运维知识库
EDIT:
Example:
//Controller
foreach($entity->allowedFields() as $key=>$value)
{
$entity->$key = $value;
}
//Entity Model
function allowedFields()
{
return $this->tableKeysAsArray;
}
Is it possible to fetch only the field names?
As simple as
$o = new Foo();
foreach ($o->fields as $key, $field)
{
echo 'Field ' . $key . ' is ' . $field .' <br>';
}
精彩评论