Created
July 5, 2011 14:21
-
-
Save adahhane/1064922 to your computer and use it in GitHub Desktop.
Other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function others(){ | |
//OLD METHOD | |
$group=new Groups(); | |
$allGroups=$group->fetchAll(); | |
$groups=array(); | |
$idGroups=array(); | |
$idMyGroups=array(); | |
$detailGroups=new GroupDetails(); | |
$dGroups=$detailGroups->fetchall(); | |
$detailGroups->setMember($this->get("Security")->getUser()->getId()); | |
$memberGroup=$detailGroups->fetch(); | |
foreach($memberGroup as $gm){ | |
foreach($dGroups as $gr){ | |
$idGroups[]=$gr->getGroups(); | |
if($gm->getGroups()==$gr->getGroups() and $gr->getMember()==$this->get("Security")->getUser()->getId()){ | |
$idMyGroups[]= $gr->getGroups(); | |
} | |
} | |
} | |
$idGroups=array_unique($idGroups); | |
$idGroup=array_diff($idGroups,$idMyGroups); | |
foreach($idGroup as $item){ | |
foreach($allGroups as $group){ | |
if($item==$group->getId()){ | |
$groups[]=$group; | |
} | |
} | |
} | |
//New Method | |
$query=new QueryBuilder(); | |
$result=$query->query('SELECT * FROM groups where id not in (SELECT groups from groupdetails where member='.$this->get("Security")->getUser()->getId().')'); | |
foreach($result as $item){ | |
echo $item['id']; | |
} | |
$this->view('groups','others',compact('groups')); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment