本文整理汇总了PHP中AJXP_Utils::regexpToLike方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::regexpToLike方法的具体用法?PHP AJXP_Utils::regexpToLike怎么用?PHP AJXP_Utils::regexpToLike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Utils
的用法示例。
在下文中一共展示了AJXP_Utils::regexpToLike方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsersCount
public function getUsersCount($baseGroup = "/", $regexp = "", $filterProperty = null, $filterValue = null, $recursive = true)
{
$this->connect();
$ands = array();
if (!empty($regexp)) {
$select = "SELECT COUNT(*) FROM [" . $this->customTableName . "] WHERE %and";
$ands[] = array("[" . $this->customTableUid . "] " . AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanRegexp($regexp));
$res = dibi::query($select);
} else {
$select = "SELECT COUNT(*) FROM [" . $this->customTableName . "]";
$res = dibi::query($select, $ands);
}
$this->close();
return $res->fetchSingle();
}
示例2: listRepositoriesWithCriteria
/**
* Returns a list of available repositories (dynamic ones only, not the ones defined in the config file).
* @param Array $criteria
* @param int $count possible total count
* @return Repository[]
*/
public function listRepositoriesWithCriteria($criteria, &$count = null)
{
$wheres = array();
$limit = $groupBy = "";
$order = "ORDER BY display ASC";
if (isset($criteria["role"]) && is_a($criteria["role"], "AJXP_Role")) {
return $this->listRepositoriesForRole($criteria["role"]);
}
$searchableKeys = array("uuid", "parent_uuid", "owner_user_id", "display", "accessType", "isTemplate", "slug", "groupPath");
foreach ($criteria as $cName => $cValue) {
if (in_array($cName, $searchableKeys) || in_array(substr($cName, 1), $searchableKeys)) {
if (is_array($cValue)) {
if ($cName[0] == "!") {
$cName = substr($cName, 1);
$wheres[] = array("[{$cName}] NOT IN (%s)", $cValue);
} else {
$wheres[] = array("[{$cName}] IN (%s)", $cValue);
}
} else {
if (strpos($cValue, "regexp:") === 0) {
$regexp = str_replace("regexp:", "", $cValue);
$wheres[] = array("[{$cName}] " . AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanRegexp($regexp));
} else {
if ($cValue == AJXP_FILTER_NOT_EMPTY) {
$wheres[] = array("[{$cName}] IS NOT NULL");
} else {
if ($cValue == AJXP_FILTER_EMPTY) {
$wheres[] = array("[{$cName}] IS NULL");
} else {
$type = "%s";
if ($cName == 'isTemplate') {
$type = "%b";
}
$wheres[] = array("[{$cName}] = {$type}", $cValue);
}
}
}
}
} else {
if ($cName == "CURSOR") {
$limit = $cValue;
} else {
if ($cName == "ORDERBY") {
$order = "ORDER BY " . $cValue["KEY"] . " " . $cValue["DIR"];
} else {
if ($cName == "GROUPBY") {
$groupBy = "GROUP BY " . $cValue;
}
}
}
}
}
if (isset($criteria["CURSOR"])) {
$res = dibi::query("SELECT COUNT(uuid) FROM [ajxp_repo] WHERE %and", $wheres);
$count = $res->fetchSingle();
}
if (!empty($limit) && is_array($limit)) {
$res = dibi::query("SELECT * FROM [ajxp_repo] WHERE %and {$groupBy} {$order} %lmt %ofs", $wheres, $limit["LIMIT"], $limit["OFFSET"]);
} else {
$res = dibi::query("SELECT * FROM [ajxp_repo] WHERE %and {$groupBy} {$order}", $wheres);
}
$all = $res->fetchAll();
return $this->initRepoArrayFromDbFetch($all);
}
示例3: getUsersCount
public function getUsersCount($baseGroup = "/", $regexp = "", $filterProperty = null, $filterValue = null, $recursive = true)
{
// WITH PARENT
// SELECT COUNT(*) FROM ajxp_users AS u, ajxp_user_rights AS r WHERE u.groupPath LIKE '/%' AND r.login=u.login AND r.repo_uuid = 'ajxp.parent_user'
// WITH SPECIFIC PARENT 'username'
// SELECT COUNT(*) FROM ajxp_users AS u, ajxp_user_rights AS r WHERE u.groupPath LIKE '/%' AND r.login=u.login AND r.repo_uuid = 'ajxp.parent_user' AND r.rights = 'username'
// WITHOUT PARENT
// SELECT COUNT(*) FROM ajxp_users AS u WHERE NOT EXISTS (SELECT * FROM ajxp_user_rights AS c WHERE c.login=u.login AND c.repo_uuid='ajxp.parent_user')
$ands = array();
$select = "SELECT COUNT(*) FROM [ajxp_users] AS u WHERE %and";
if (!empty($regexp)) {
$ands[] = array("[u.login] " . AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanRegexp($regexp));
}
if ($recursive) {
$ands[] = array("[u.groupPath] LIKE %like~", $baseGroup);
} else {
$ands[] = array("[u.groupPath] = %s", $baseGroup);
}
$ands[] = array("NOT EXISTS (SELECT * FROM [ajxp_user_rights] AS c WHERE [c.login]=[u.login] AND [c.repo_uuid] = 'ajxp.hidden')");
if ($filterProperty !== null && $filterValue !== null) {
if ($filterProperty == "parent") {
$filterProperty = "ajxp.parent_user";
} else {
if ($filterProperty == "admin") {
$filterProperty = "ajxp.admin";
}
}
if ($filterValue == AJXP_FILTER_EMPTY) {
$ands[] = array("NOT EXISTS (SELECT * FROM [ajxp_user_rights] AS c WHERE [c.login]=[u.login] AND [c.repo_uuid] = %s)", $filterProperty);
} else {
if ($filterValue == AJXP_FILTER_NOT_EMPTY) {
$select = "SELECT COUNT(*) FROM [ajxp_users] AS u, [ajxp_user_rights] AS r WHERE %and";
$ands[] = array("[r.login]=[u.login]");
$ands[] = array("[r.repo_uuid] = %s", $filterProperty);
} else {
$select = "SELECT COUNT(*) FROM [ajxp_users] AS u, [ajxp_user_rights] AS r WHERE %and";
$ands[] = array("[r.login]=[u.login]");
$ands[] = array("[r.repo_uuid] = %s", $filterProperty);
$ands[] = array("[r.rights] " . AJXP_Utils::likeToLike($filterValue), AJXP_Utils::cleanLike($filterValue));
}
}
}
$res = dibi::query($select, $ands);
return $res->fetchSingle();
}