【问题标题】:How can I get the column names of all entities in Symfony?如何获取 Symfony 中所有实体的列名?
【发布时间】:2020-09-12 03:45:55
【问题描述】:

像这样我可以得到我的实体“字段”的列名:

$entity_columns = $this->em->getClassMetadata('App\\Entity\\Fields')->getColumnNames();

有没有一种快速的方法来一次获取所有实体的列?

【问题讨论】:

    标签: php symfony entity metadata


    【解决方案1】:

    我没有找到任何内置的方法来做到这一点,但也许你可以这样做:

    $declared = get_declared_classes();
    foreach ( $declared as $class ) {
        if ( preg_match( "/App\\\Entity/", $class) ){
            $entityData = $this->manager->getClassMetadata( $class );
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-02
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2020-03-12
      相关资源
      最近更新 更多