【问题标题】:Is it possible to fetch the names of the fields a table has, using Datamapper with Codeigniter?是否可以使用带有 Codeigniter 的 Datamapper 来获取表的字段名称?
【发布时间】:2011-07-27 17:00:36
【问题描述】:

我需要从表中获取字段,以便检查该特定表是否接受键/值对。是否可以仅获取字段名称? 我正在使用 Datamapper 和 Codeigniter。

编辑:

例子:

//Controller
foreach($entity->allowedFields() as $key=>$value)
{
  $entity->$key = $value;
}

//Entity Model
function allowedFields()
{
  return $this->tableKeysAsArray;
}

【问题讨论】:

    标签: php codeigniter orm


    【解决方案1】:

    Is it possible to fetch only the field names?就这么简单

    $o = new Foo();
    
    foreach ($o->fields as $key, $field)
    {
       echo 'Field ' . $key . ' is ' . $field .' <br>';
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-19
      • 2014-08-10
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 2016-06-22
      相关资源
      最近更新 更多