任何人都可以告訴我如何使用輸入'findby'作爲對象數組? 我有這樣的代碼:如何使用輸入爲數組的「findby」原則?
public function getIpOnline($acc)
{
try {
$rs = $this->em
->getRepository($this->target)
->findBy(array('login' => $acc))
;
} catch (Exception $e) {
echo "ERROR ".$this->target." DAO: ".$e;
}
var_dump($rs);exit();
return $rs;
}
我得到了錯誤:
Catchable fatal error: Object of class Character could not be converted to string in /var/www/xxx.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php on line 67
在此先感謝。
可以ü請詳細告訴我?我不明白。 – Hanata
@Hanata在函數getRepository($ repoName);你必須傳遞實體的類名稱。例如你可以輸入'Product \ Entity \ Phone',或者使用函數get_class($ object),或者使用Product :: class。所有這些知識將返回具有類/對象名稱空間的完整類名稱。 – Maytyn