Tag: 学说的

Doctrine 2 – 在ManyToOne关系的外键上不允许空值

在我的一个实体中有一个ManyToOne关系,如下所示: class License { // … /** * Customer who owns the license * * @var \ISE\LicenseManagerBundle\Entity\Customer * @ORM\ManyToOne(targetEntity="Customer", inversedBy="licenses") * @ORM\JoinColumn(name="customer_id", referencedColumnName="id") */ private $customer; // … } class Customer { // … /** * Licenses that were at one point generated for the customer * * @var \Doctrine\Common\Collections\ArrayCollection * @ORM\OneToMany(targetEntity="License", mappedBy="customer") */ private […]

学说 – 如何打印出真正的SQL,而不仅仅是准备好的声明?

我们正在使用一个PHP ORM Doctrine。 我正在创build一个这样的查询: $q = Doctrine_Query::create()->select('id')->from('MyTable'); 然后在函数中添加各种where子句和适当的东西,就像这样 $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); 之后,在execute()该查询对象之前,我想打印出原始SQL以检查它,并执行以下操作: $q->getSQLQuery(); 但是,只打印准备的语句,而不是完整的查询。 我想看看它发送给MySQL,而是打印出一个准备好的声明,包括? 的。 有没有办法看到“完整”的查询?