Questions tagged [doctrine-native-query]
7 questions
3
votes
1 answer
How to get non-mapped column in a result of Doctrine native query
How can I get non-mapped column in result from native query?
My query:
$query = $this->getEntityManager()->createNativeQuery(
"SELECT m.id, m.title, MATCH(m.title) AGAINST('$slug') AS score "
. "FROM music AS m "
…

MonkeyOne
- 58
- 1
- 7
2
votes
0 answers
Doctrine query result is empty but the generated running query works in Postgres
I have a native query in Doctrine, which generate the right SQL, which runs in PostgreSQL. However the Doctrine returns null/empty results.
public count unReadedNotifications(User $user) {
$rsm = new ResultSetMapping();
$sql =
…

Dabagab
- 2,497
- 4
- 26
- 31
1
vote
1 answer
ResultSetMapping addScalarResult associative array
In my project with Symfony2, I'm using Doctrine createNativeQuery, and I would like to get an associative array.
This is my code
$rsm = new ResultSetMapping;
$rsm->addScalarResult('id', 'id');
$rsm->addScalarResult('name',…

jjgarcía
- 589
- 1
- 4
- 26
1
vote
1 answer
doctrine Add_date in native query
I want to select data from table using native query and DATE_ADD but always I got an errors,
this is my sql request:
$qb = $this->_em->createNativeQuery("select Coalesce (sum(p.nb_sms*p.nb_destination),0) as multiplesms , sum(p.nb_fax) as nbFax,…

Majdi Taleb
- 731
- 3
- 9
- 26
1
vote
1 answer
Doctrine native query self join without join column?
I want to do self join between A and well A.
It works as long as I do not try to select fields from joined self.
So:
SELECT a.id
FROM A AS a
LEFT JOIN A AS a2;
Will work (or at least throw no exceptions/errors).
While:
SELECT a.id, a2.id AS…

przemo_li
- 3,932
- 4
- 35
- 60
0
votes
1 answer
Doctrine ORM nativeQuery: How to rename table
I'm trying to rename a table with nativeQuery like this:
$rsm = new ResultSetMapping();
$query = $em->createNativeQuery('RENAME TABLE `'.$oldname.'` TO `'.$newname.'`', $rsm);
$result = $query->getResult();
Strangely the table gets renamed, but…

Onki Hara
- 270
- 1
- 9
0
votes
1 answer
Doctrine hydrate only single row from native query
Here is my mappings:
$rsm = new ResultSetMapping;
$rsm->addEntityResult('OOHMediaBundle:OfferItem', 'i');
$rsm->addFieldResult('i', 'reserved_at', 'reservedAt');
$rsm->addJoinedEntityResult('OOHMediaBundle:Offer', 'o', 'i', 'offer');
…

przemo_li
- 3,932
- 4
- 35
- 60