11
我在執行Doctrine DQL查詢時遇到問題。這是它給我的錯誤。Doctrine 2 PlainValue expected
Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue,
got 'integer' at position 13 in property Base\Session::$lifetime.
我的代碼如下所示:
$query = $em->createQuery("SELECT s FROM Base\Session s WHERE s.session = \"$id\"");
其中$ id是當前的session_id。我的模型看起來像:
namespace Base;
/** @Entity @Table(name="session") */
class Session extends Skeleton {
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/** @Column(length=32) */
protected $session;
/** @Column(type=integer) */
protected $lifetime;
/** @Column(type=integer) */
protected $modified;
/** @Column(type="text") */
protected $data;
}
謝謝。第一個錯誤是解決方案。我已經知道你的第二點。剛剛嘗試了很多東西,結果我忘了使用準備好的語句。非常感謝! – 2010-08-18 09:22:22
作爲對#1的補充評論,單引號也不起作用,必須使用雙引號 – Shawn 2013-09-05 15:24:32