Doctrine 2.0 Resultset Mapping is used incorrectly?

2.1k views Asked by At

I'm having a problem with Doctrine's ResultSetMapping when trying to do a native query.

$sql = "SELECT id, thesis "
     . "FROM activity p "
     . "WHERE MATCH (thesis) AGAINST ('Gun') ";

$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('activity\models\Entities\Opinion', 'p');
$rsm->addFieldResult('p', 'id', 'id');
$rsm->addFieldResult('p', 'thesis', 'thesis');

$query = $this->_em->createNativeQuery($sql, $rsm);

$results = $query->getResult();

return $results;

I know for a fact that the sql side is finding thing because first of all, there are entries in the database that have the world "gun" in them, and it gives me an error if I change it to something that's not in the database.

That leaves the resultsetmapping code. It's not producing any errors, but the array returned by getResult() is blank. this makes me suspect that I did the mapping incorrectly.

Do you guys have any suggestions as to what I can do to further identify what the problem is?

1

There are 1 answers

0
NightRaven On BEST ANSWER

it turns out the problem is that MATCH AGAINST does not work if the query is less than 4 letters. the problem was the sql afterall :(

The resultsetmapping is working perfectly.