【问题标题】:doctrine2 arraycollection count() php教义2数组集合计数()php
【发布时间】:2013-01-26 17:23:06
【问题描述】:

我有以下代码:

        $countries = $em->getRepository("country")->findAll();
        $array = array();
        $count = 0;
        foreach($countries as $country){
            if(is_object($country)){
                if($country->getCompaniesCount() > 0)
                $array[$count] = $country;
                $count++;
            }
        }

调用的“getCompaniesCount”函数如下所示:

    public function getCompaniesCount(){
        return $this->_comapanies->count();
    }

但它会产生一个我无法理解的错误。

“国家”中有“国家”,“国家”中有“公司”。 所以国家和公司是多对多关系。并且“country”中的属性“_companies”被初始化为一个ArrayCollection来保存公司。

但是每次我运行这段代码时都会出现以下错误:

Catchable fatal error: 
Argument 1 passed to   Doctrine\ORM\Mapping\DefaultQuoteStrategy::getJoinTableName() must be an array, null given, 
called in /usr/share/pear/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 965 
and defined in /usr/share/pear/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php on line 86

有人知道为什么吗?

谢谢

【问题讨论】:

    标签: php doctrine doctrine-orm arraycollection


    【解决方案1】:

    哦哦不。我觉得很愚蠢。 只是一个错误的外键名-.-.

    解决了。

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      相关资源
      最近更新 更多