Код: Выделить всё
$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++;
}
}
Код: Выделить всё
public function getCompaniesCount(){
return $this->_comapanies->count();
}
Есть страны в «стране», и там ЯВЛЯЮТСЯ «компаниями», которые связаны со странами.
поэтому страна и компания представляют собой отношения ManyToMany. А атрибут «_companies» в «country» инициализируется как 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
спасибо
Подробнее здесь: https://stackoverflow.com/questions/145 ... -count-php
Мобильная версия