我需要从表中获取字段,以便检查该特定表是否接受键/值对。是否可以仅获取字段名称? 我正在使用Datamapper和Codeigniter。
编辑:
示例:
//Controller
foreach($entity->allowedFields() as $key=>$value)
{
$entity->$key = $value;
}
//Entity Model
function allowedFields()
{
return $this->tableKeysAsArray;
}
答案 0 :(得分:2)
Is it possible to fetch only the field names?
就像
$o = new Foo();
foreach ($o->fields as $key, $field)
{
echo 'Field ' . $key . ' is ' . $field .' <br>';
}