我的Zend PHP堆栈使Doctrine2正常工作。
但是,如果我想使用Doctrine_Expression,
$item->setDateCreated(new Doctrine_Expression('NOW()'));
然后我收到以下错误'没有打开连接'。 这是堆栈跟踪:
#0 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Manager.php(264): Doctrine_Manager->getCurrentConnection()
#1 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Expression.php(72): Doctrine_Manager::connection()
#2 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Expression.php(116): Doctrine_Expression->getConnection()
#3 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Expression.php(133): Doctrine_Expression->parseExpression('NOW()')
#4 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Expression.php(89): Doctrine_Expression->parseClause('NOW()')
#5 D:\data\wamp\bin\php\php5.3.5\PEAR\Doctrine\Expression.php(60): Doctrine_Expression->setExpression('NOW()')
#6 D:\data\work\gazette\Projects\NorskTipping\admin-system\code\application\library\MagicHeads\Knalledge\Models\Tagging.php(91): Doctrine_Expression->__construct('NOW()')
...
#14 {main}
我尝试添加连接
$item->setDateCreated(new Doctrine_Expression('NOW()', $this->_em->getConnection()));
然而,它发生的是Doctrine\DBAL\Connection类型的连接,而Doctrine_Expression需要Doctrine_Connection
如何获取Doctrine_Connection并将其提供给Doctrine_Expression?
答案 0 :(得分:3)
Doctrine_Expression是一个Doctrine 1类,不能与Doctrine 2一起使用。这两个版本非常不同且不兼容。