--- a/Entity/DocumentRepository.php Sun Nov 06 23:45:50 2011 +0100
+++ b/Entity/DocumentRepository.php Mon Nov 07 17:25:39 2011 +0100
@@ -4,7 +4,7 @@
use Doctrine\ORM\EntityRepository;
use IRI\Bundle\WikiTagBundle\Entity\Document;
-
+use Doctrine\ORM\Query\ResultSetMapping;
use \ReflectionClass;
/**
@@ -206,5 +206,42 @@
$document->setTagsStr(implode(",",$tagstr));
$this->getEntityManager()->persist($document);
}
+
+ /**
+ *
+ * Enter description here ...
+ * @param array $values : key: the fields to search into, value array('value'=>value, 'weight'=>weight)
+ * @param unknown_type $conditions
+ */
+ function search(array $values, array $conditions=NULL)
+ {
+/* $em = $this->getEntityManager();
+
+ $rsm = new ResultSetMapping();
+ $rsm->addEntityResult("IRI/Bundle/WikiTagBundle/Entity/Document", "d");
+ $rsm->addFieldResult("d", "id", "id");
+ $rsm->addFieldResult("d", "external_id", "externalId");
+ $rsm->addScalarResult("d", "score");
+
+ $score = "";
+ foreach ($values as $fielddef) {
+
+ $columns = $fielddef["columns"];
+ $value = $fielddef["value"];
+ $value = isset($fielddef["weight"])?$fielddef["weight"]:1.0;
+
+ $score = "(MATCH($columns) AGAINST (:value))*:weight";
+ $parameters[] =
+ }
+
+
+ $query = $em->createNativeQuery("SELECT d.id, d.external_id, MATCH(title) AGAINST('$value') FROM wikitag_document d WHERE MATCH(title) AGAINST('$value') > 0", $rsm);
+
+ $res = $query->getScalarResult();
+
+ return $res;*/
+
+
+ }
}
\ No newline at end of file