@ 2014-08-19T11:08:37Z <?php
class ProfileRepository extends EntityRepository{
public function getProfilesExperimental($searchString, $isMapSearch = false){
$searchString = strtolower($searchString);
$em = $this->getEntityManager();
$cit = $em->getRepository('LunnarBundle:City')->findAll();
$cat = $em->getRepository('LunnarBundle:Profilecategory')->findAll();
$bra = $em->getRepository('LunnarBundle:Brand')->findAll();
$cities = array();
$profilecategories = array();
$brands = array();
foreach($cit as $city){
array_push($cities, strtolower($city->getName()));
}
foreach($cat as $category){
array_push($profilecategories, strtolower($category->getName()));
}
foreach($bra as $brand){
array_push($brands, strtolower($brand->getName()));
}
$parameters = array();
//'var' => '%'.$searchString.'%',
$searchQuerySelectJoin = "SELECT p FROM LunnarBundle:Profile p LEFT JOIN p.divisions d ";
$searchQueryWhere = "";
//////////////////////////
$searchStringArray = explode(" ", $searchString);
// Remove í, á and við
$removeWords = array('í','á','við');
//Find city, category, brand and save for later, and remove them from $searchStringArray
$searchStringArray = array_diff($searchStringArray, $removeWords);
$city = array_intersect($searchStringArray, $cities);
$searchStringArray = array_diff($searchStringArray, $city);
$category = array_intersect($searchStringArray, $profilecategories);
$searchStringArray = array_diff($searchStringArray, $category);
$brand = array_intersect($searchStringArray, $brands);
$searchStringArray = array_diff($searchStringArray, $brand);
//// PRINTS
print_r($searchStringArray);
echo '<br/>';
//print_r($city);
//print_r($profilecategory);
//print_r($brand);
$first = true;
$searchTerms = " ";
if (sizeof($searchStringArray)>0){
$searchTerms = current($searchStringArray);
$parameters['var'] = "%".$searchTerms."%";
$searchQueryWhere = "WHERE ( p.name LIKE :var ".$searchQueryWhere;
$first = false;
} elseif (sizeof($searchStringArray)==0){
$searchQueryWhere = " WHERE ( ".$searchQueryWhere;
}
if ($category){
$parameters['category'] = $category;
$searchQuerySelectJoin .= " LEFT JOIN p.profilecategory pc ";
if (!$first){
$searchQueryWhere .= " AND pc.name = :category ";
}else {
$first = false;
$searchQueryWhere .= " pc.name = :category ";
}
}
if ($brand){
$parameters['brand'] = $brand;
$searchQuerySelectJoin .= " LEFT JOIN p.brand b ";
if (!$first){
$searchQueryWhere .= " AND b.name = :brand ";
}else {
$first = false;
$searchQueryWhere .= " b.name = :brand ";
}
}
if ($city){
$parameters['city'] = $city;
$searchQuerySelectJoin .= " LEFT JOIN d.city c ";
if (!$first){
$searchQueryWhere .= " AND c.name = :city ";
}else {
$first = false;
$searchQueryWhere .= " c.name = :city ";
}
}
//////////////////////////
if($isMapSearch == true){
$searchQuery .= "AND d.latitude IS NOT NULL ";
}
$searchQuery = $searchQuerySelectJoin.$searchQueryWhere." ) ORDER BY p.name ASC";
echo $searchQuery;
$query = $this->getEntityManager()
->createQuery(
$searchQuery
)->setParameters($parameters);
return $query->getResult();
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Class "EntityRepository" not found in /in/IUQt1:3
Stack trace:
#0 {main}
thrown in /in/IUQt1 on line 3
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
41.02 ms | 401 KiB | 8 Q