本文整理匯總了PHP中SqlParser::addField方法的典型用法代碼示例。如果您正苦於以下問題:PHP SqlParser::addField方法的具體用法?PHP SqlParser::addField怎麽用?PHP SqlParser::addField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SqlParser
的用法示例。
在下文中一共展示了SqlParser::addField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getGroup
/**
* 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;
}