Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top