I have the following code:
/**
* Search similar category given a string
*
* @param $searchTerm search similar category
*/
public function findOneSimilarCategory($searchTerm)
{
$query = $this->createQueryBuilder('secondLevelCategory')
->select('secondLevelCategory')
->where('secondLevelCategory.categoryTitle LIKE :searchTerm')
->setParameter('searchTerm', $searchTerm)
->getQuery();
$query->useResultCache(true, self::CACHE_RESULT_LIFETIME, md5(__METHOD__ . serialize('category-search-' . $query->getParameters())));
$query->useQueryCache(true);
return $query->getSingleResult();
}
however this gives me an error:
"PHP message: PHP Fatal error: Uncaught exception 'Doctrine\ORM\NoResultException' with message 'No result was found for query although at least one row was expected.' in /var/www/Shopious/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:649