doctrine-query

Doctrine - How to print out the real sql, not just the prepared statement?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 06:13:07
We're using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select('id')->from('MyTable'); and then in the function I'm adding in various where clauses and things as appropriate, like this $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); Later on, before execute() -ing that query object, I want to print out the raw SQL in order to examine it, and do this: $q->getSQLQuery(); However that only prints out the prepared statement, not the full query. I want to see what it is sending to the MySQL, but instead it is printing out a

Regex with Doctrine 2 query builder?

老子叫甜甜 提交于 2019-11-27 03:53:17
问题 As per the title, how would one match on a regular expression with the Doctrine 2 query builder? Basically I'm trying to generate unique slugs. Here is my current implementation. I generate the slug. I then check to see if there are any slugs in use like this slug. If there are, I will append a -{number} to the end of the slug where {number} is the lowest number not already in use. $qb->select(array('partial o.{id, slug}')) ->from('Foo\Bar\Entity\Object', 'o') ->where($qb->expr()->like('o

How to fetch class instead of array in Doctrine 2

可紊 提交于 2019-11-27 01:52:51
问题 I am able to fetch my data from database by using this structure: $user = $this->getDoctrine() ->getRepository('AcmeDemoBundle:Emails') ->find(8081); When I do that, I am able to get my data like this: $user->getColumnNameHere(); Basically I am able to use Entity Class. But if I want to use QueryBuilder instead of find I am only getting associative arrays. $product->createQueryBuilder('p') ->setMaxResults(1) ->where('p.idx = :idx') ->select('p.columnNameHere') ->setParameter('idx', 8081) -

Doctrine - How to print out the real sql, not just the prepared statement?

久未见 提交于 2019-11-26 10:16:12
问题 We\'re using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select(\'id\')->from(\'MyTable\'); and then in the function I\'m adding in various where clauses and things as appropriate, like this $q->where(\'normalisedname = ? OR name = ?\', array($string, $originalString)); Later on, before execute() -ing that query object, I want to print out the raw SQL in order to examine it, and do this: $q->getSQLQuery(); However that only prints out the prepared