doctrine2 ArrayCollection的计数()PHP

问题描述 投票:1回答:1

我有以下代码:

        $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();
    }

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

还有在“国家”的国家,并有“公司”这是有关国家。所以国家和公司是一个多对多关联关系。而在“国”属性“_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个回答
0
投票

哦~~ NOOOO。我感觉如此的愚蠢。只是一个错误的外键名-.-。

解决了。

© www.soinside.com 2019 - 2024. All rights reserved.