示例#1
0
 /**
  * returns a list  of the groups that the user is part of
  * @param array identifier (key = name of identifier, valeu = value)
  * @return array
  */
 public function getGroup($searchcriteria)
 {
     $sqlParser = new SqlParser();
     $sqlParser->setSelect('select distinct');
     $sqlParser->setTable('usergroup', 'a');
     $sqlParser->addField(new SqlField('a', 'usr_id', 'usr_id', 'id', SqlParser::SEL_DETAIL, SqlField::TYPE_INTEGER));
     $sqlParser->addField(new SqlField('a', 'grp_id', 'grp_id', 'id', SqlParser::SEL_LIST, SqlField::TYPE_INTEGER));
     $sqlParser->parseCriteria($searchcriteria);
     $query = $sqlParser->getSql(SqlParser::SEL_LIST);
     //$query = sprintf("select distinct a.grp_id as grp_id from usergroup as a where a.usr_id %s", $users);
     $db = $this->getDb();
     $res = $db->query($query);
     if ($db->isError($res)) {
         throw new Exception($res->getDebugInfo());
     }
     $retval = array();
     while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
         $retval[] = $row['grp_id'];
     }
     return $retval;
 }