【问题标题】:Fatal error: Function name must be a string doctrine and Zend 2致命错误:函数名必须是字符串学说和 Zend 2
【发布时间】:2023-03-09 09:36:01
【问题描述】:

我的课程包含外键,我想在我的课程中插入这个外键

我使用教义 2 和 zend 2 编写该脚本:

$geographicalarea = new Geographicalarea();
$geographicalarea = $entityManager()->getRepository('\Synchro\Entity\Geographicalarea')->find (array('idGeographicalArea'=> $idgeographicalarea ));

echo "Create ";
$department = new Department();
$department->setNamedepartment($data ['nameDepartment']);
$department->setCodedepartment($data ['codeDepartment']);
$department->setIdfkgeographicalarea($geographicalarea);

我得到这个错误:

致命错误:函数名必须是字符串 C:\wamp\www\imprimvert\module\Synchro\src\Synchro\Service\DepartmentManager.php 在第 88 行

$geographicalarea = $entityManager()->getRepository('\Synchro\Entity\Geographicalarea')->find (array('idGeographicalArea'=> $idgeographicalarea ));

我该如何解决?

提前致谢

【问题讨论】:

  • Doctrine 存储库使用神奇的 __call() 方法来代理 find* 方法,可能是它在您的方法调用中阻塞了空间。尝试在此时删除空格)->find (array(,使其看起来像这样)->find(array(
  • 总是我有同样的错误我删除了查找之间的空间但我有同样的错误

标签: php doctrine-orm zend-framework2


【解决方案1】:

你写了$entityManager() 但我敢打赌$entityManager 是一个对象。

去掉括号():

$geographicalarea = $entityManager->getRepository('\Synchro\Entity\Geographicalarea')->find (array('idGeographicalArea'=> $idgeographicalarea ));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    相关资源
    最近更新 更多