本文整理汇总了PHP中CriteriaCompo::renderWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP CriteriaCompo::renderWhere方法的具体用法?PHP CriteriaCompo::renderWhere怎么用?PHP CriteriaCompo::renderWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CriteriaCompo
的用法示例。
在下文中一共展示了CriteriaCompo::renderWhere方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: myDeleteByModule
function myDeleteByModule($DB, $gperm_modid, $gperm_name = null, $gperm_itemid = null)
{
$criteria = new CriteriaCompo(new Criteria('gperm_modid', intval($gperm_modid)));
if (isset($gperm_name)) {
$criteria->add(new Criteria('gperm_name', $gperm_name));
if (isset($gperm_itemid)) {
$criteria->add(new Criteria('gperm_itemid', intval($gperm_itemid)));
}
}
$sql = "DELETE FROM " . $DB->prefix('group_permission') . ' ' . $criteria->renderWhere();
$result = $DB->query($sql);
$result = $result ? true : false;
return $result;
}
示例2: synchronize
/**
* @param $uid
* @param $type
*/
function synchronize($uid, $type)
{
global $xoopsDB;
include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
include_once XOOPS_ROOT_PATH . '/kernel/module.php';
$tables = array();
// Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
$tables[] = array('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
// Count Content posts
if (XoopsModule::getByDirname('fmcontent')) {
$tables[] = array('table_name' => 'fmcontent_content', 'uid_column' => 'content_uid');
}
// Count forum posts
if (XoopsModule::getByDirname('newbb')) {
$tables[] = array('table_name' => 'bb_posts', 'uid_column' => 'uid');
}
switch ($type) {
case 'user':
$total_posts = 0;
foreach ($tables as $table) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria($table['uid_column'], $uid));
if (!empty($table['criteria'])) {
$criteria->add($table['criteria']);
}
$sql = 'SELECT COUNT(*) AS total FROM ' . $xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
if ($result = $xoopsDB->query($sql)) {
if ($row = $xoopsDB->fetchArray($result)) {
$total_posts += $row['total'];
}
}
}
$sql = 'UPDATE ' . $xoopsDB->prefix('users') . " SET posts = '" . $total_posts . "' WHERE uid = '" . $uid . "'";
if (!($result = $xoopsDB->queryF($sql))) {
redirect_header('admin.php?fct=users', 1, _AM_SYSTEM_USERS_CNUUSER);
}
break;
case 'all users':
$sql = 'SELECT uid FROM ' . $xoopsDB->prefix('users') . '';
if (!($result = $xoopsDB->query($sql))) {
redirect_header('admin.php?fct=users', 1, sprintf(_AM_SYSTEM_USERS_CNGUSERID, $uid));
}
while ($data = $xoopsDB->fetchArray($result)) {
synchronize($data['uid'], 'user');
}
break;
}
// exit();
}
示例3: array
/**
* Get configs from a certain category
*
* @param int $category ID of a category
* @param int $module ID of a module
*
* @return array array of {@link XoopsConfig}s
* @todo This method keeps cache for categories. This may be problem...
*/
function &getConfigsByCat($category, $module = 0)
{
static $_cachedConfigs = array();
if (!empty($_cachedConfigs[$module][$category])) {
return $_cachedConfigs[$module][$category];
} else {
$ret = array();
$criteria = new CriteriaCompo(new Criteria('conf_modid', (int) $module));
if (!empty($category)) {
$criteria->add(new Criteria('conf_catid', (int) $category));
}
// get config values
$configs = array();
$db = $this->_cHandler->db;
$result = $db->query('SELECT conf_name,conf_value,conf_valuetype FROM ' . $db->prefix('config') . ' ' . $criteria->renderWhere() . ' ORDER BY conf_order ASC');
if ($result) {
while (list($name, $value, $type) = $db->fetchRow($result)) {
switch ($type) {
case 'array':
$ret[$name] = unserialize($value);
break;
case 'encrypt':
$ret[$name] = XCube_Utils::decrypt($value);
break;
default:
$ret[$name] = $value;
}
}
$_cachedConfigs[$module][$category] =& $ret;
}
return $ret;
}
}
示例4: array
/** get details of a word in a category.
@return array ('count' => count)
@param string word
@param string category id
*/
function getWord($word, $category_id)
{
$details = array();
$crit = new CriteriaCompo(new Criteria('word', $word));
$crit->add(new Criteria('category_id', $category_id));
$ret = $this->con->query('SELECT count FROM ' . $this->con->prefix('xhelp_bayes_wordfreqs') . $crit->renderWhere());
if (!$ret) {
$details['count'] = 0;
} else {
$details = $this->con->fetchRow($ret);
}
return $details;
}
示例5: getActiveModules
function getActiveModules()
{
//
// At first, get active module IDs.
//
static $ret;
if (isset($ret)) {
return $ret;
}
$handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('isactive', 1));
$criteria->add(new Criteria('hassearch', 1));
// shortcut for speedup
$db = $handler->db;
$sort = $criteria->getSort();
$sql = 'SELECT mid,name FROM ' . $db->prefix('modules') . ' ' . $criteria->renderWhere() . ($sort ? ' ORDER BY ' . $sort . ' ' . $criteria->getOrder() : ' ORDER BY weight ' . $criteria->getOrder() . ', mid ASC');
$result = $db->query($sql);
$handler =& xoops_gethandler('groupperm');
$groupArr = Legacy_SearchUtils::getUserGroups();
$ret = array();
while (list($mid, $name) = $db->fetchRow($result)) {
if ($handler->checkRight('module_read', $mid, $groupArr)) {
$ret[] = array('mid' => $mid, 'name' => $name);
}
}
return $ret;
}
示例6: getAllSubmitted
/**
* Get all submitted stories awaiting approval
*
* @param int $limit Denotes where to start the query
* @param boolean $asobject true will returns the stories as an array of objects, false will return storyid => title
* @param boolean $checkRight whether to check the user's rights to topics
*/
function getAllSubmitted($limit = 0, $asobject = true, $checkRight = false, $start = 0)
{
$db =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
$ret = array();
$criteria = new CriteriaCompo(new Criteria('published', 0));
if ($checkRight) {
global $xoopsUser;
if (!is_object($xoopsUser)) {
return $ret;
}
$allowedtopics = news_MygetItemIds('news_approve');
$criteria2 = new CriteriaCompo();
foreach ($allowedtopics as $key => $topicid) {
$criteria2->add(new Criteria('topicid', $topicid), 'OR');
}
$criteria->add($criteria2);
}
$sql = 'SELECT s.*, t.* FROM ' . $db->prefix('stories') . ' s, ' . $db->prefix('topics') . ' t ';
$sql .= ' ' . $criteria->renderWhere() . ' AND (s.topicid=t.topic_id) ORDER BY created DESC';
$result = $db->query($sql, intval($limit), intval($start));
while ($myrow = $db->fetchArray($result)) {
if ($asobject) {
$ret[] = new NewsStory($myrow);
} else {
$ret[$myrow['storyid']] = $myts->htmlSpecialChars($myrow['title']);
}
}
return $ret;
}
示例7: synchronize
function synchronize($id, $type)
{
global $xoopsDB;
switch ($type) {
case 'user':
$id = intval($id);
// Array of tables from which to count 'posts'
$tables = array();
// Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
$tables[] = array('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
// Count forum posts
$tables[] = array('table_name' => 'bb_posts', 'uid_column' => 'uid');
$total_posts = 0;
foreach ($tables as $table) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria($table['uid_column'], $id));
if (!empty($table['criteria'])) {
$criteria->add($table['criteria']);
}
$sql = "SELECT COUNT(*) AS total FROM " . $xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
if ($result = $xoopsDB->query($sql)) {
if ($row = $xoopsDB->fetchArray($result)) {
$total_posts = $total_posts + $row['total'];
}
}
}
$sql = "UPDATE " . $xoopsDB->prefix("users") . " SET posts = {$total_posts} WHERE uid = {$id}";
if (!($result = $xoopsDB->query($sql))) {
exit(sprintf(_AM_CNUUSER % s, $id));
}
break;
case 'all users':
$sql = "SELECT uid FROM " . $xoopsDB->prefix("users") . "";
if (!($result = $xoopsDB->query($sql))) {
exit(_AM_CNGUSERID);
}
while ($row = $xoopsDB->fetchArray($result)) {
$id = $row['uid'];
synchronize($id, "user");
}
break;
default:
break;
}
redirect_header("admin.php?fct=users&op=modifyUser&uid=" . $id, 1, _AM_DBUPDATED);
exit;
}
示例8: array
include_once XOOPS_ROOT_PATH . '/modules/system/include/functions.php';
$tables = array();
// Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
$tables[] = array('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
// Count forum posts
if (XoopsModule::getByDirname("newbb")) {
$tables[] = array('table_name' => 'bb_posts', 'uid_column' => 'uid');
}
$uid = system_CleanVars($_REQUEST, 'uid', int);
$total_posts = 0;
foreach ($tables as $table) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria($table['uid_column'], $uid));
if (!empty($table['criteria'])) {
$criteria->add($table['criteria']);
}
$sql = "SELECT COUNT(*) AS total FROM " . $xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
if ($result = $xoopsDB->query($sql)) {
if ($row = $xoopsDB->fetchArray($result)) {
$total_posts = $total_posts + $row['total'];
}
}
}
$sql = "UPDATE " . $xoopsDB->prefix("users") . " SET posts = '" . $total_posts . "' WHERE uid = '" . $uid . "'";
if (!($result = $xoopsDB->queryF($sql))) {
redirect_header("admin.php?fct=users", 1, _AM_SYSTEM_USERS_CNUUSER);
} else {
echo $total_posts;
}
break;
}
示例9: getGrantedItems
/**
* Returns permissions for a certain type
*
* @param string $gperm_name "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
* @param int $id id of the item (forum, topic or possibly post) to get permissions for
*
* @return array
*/
public function getGrantedItems($gperm_name, $id = null)
{
global $xoopsUser;
static $permissions;
if (!isset($permissions[$gperm_name]) || $id != null && !isset($permissions[$gperm_name][$id])) {
//Instead of calling groupperm handler and get objects, we will save some memory and do it our way
$criteria = new CriteriaCompo(new Criteria('gperm_name', $gperm_name));
$criteria->add(new Criteria('gperm_modid', $this->publisher->getModule()->getVar('mid')));
//Get user's groups
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
$criteria2 = new CriteriaCompo();
foreach ($groups as $gid) {
$criteria2->add(new Criteria('gperm_groupid', $gid), 'OR');
}
$criteria->add($criteria2);
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'SELECT * FROM ' . $db->prefix('group_permission');
$sql .= ' ' . $criteria->renderWhere();
$result = $db->query($sql, 0, 0);
$permissions[$gperm_name] = array();
while ($myrow = $db->fetchArray($result)) {
$permissions[$gperm_name][] = $myrow['gperm_itemid'];
}
$permissions[$gperm_name] = array_unique($permissions[$gperm_name]);
}
//Return the permission array
return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : array();
}
示例10: array
/**
* Get a list of {@link SmartmediaFolder} objects for the search feature
*
* @param array $queryarray list of keywords to look for
* @param string $andor specify which type of search we are performing : AND or OR
* @param int $limit maximum number of results to return
* @param int $offset at which folder shall we start
* @param int $userid userid related to the creator of the folder
*
* @return array array containing information about the folders mathing the search criterias
*/
function &getObjectsForSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
{
global $xoopsConfig;
$ret = array();
$sql = "SELECT item." . $this->_key_field . ", itemtext." . $this->_caption_field . ", itemtext.description, parent.categoryid FROM\r\n (\r\n \t\t\t (" . $this->_db->prefix($this->_dbtable) . " AS item\r\n\t\t\t\t\t INNER JOIN " . $this->_db->prefix($this->_dbtable) . "_text AS itemtext \r\n \t\t ON item." . $this->_key_field . " = itemtext." . $this->_key_field . "\r\n \t\t )\r\n \t\t INNER JOIN " . $this->_db->prefix($this->_dbtable_parent) . " AS parent\r\n \t\t ON parent." . $this->_key_field . " = item." . $this->_key_field . "\r\n )";
if ($queryarray) {
$criteriaKeywords = new CriteriaCompo();
for ($i = 0; $i < count($queryarray); $i++) {
$criteriaKeyword = new CriteriaCompo();
$criteriaKeyword->add(new Criteria('itemtext.title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
$criteriaKeyword->add(new Criteria('itemtext.description', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
$criteriaKeywords->add($criteriaKeyword, $andor);
}
}
if ($userid != 0) {
$criteriaUser = new CriteriaCompo();
$criteriaUser->add(new Criteria('item.uid', $userid), 'OR');
}
$criteria = new CriteriaCompo();
// Languageid
$criteriaLanguage = new CriteriaCompo();
$criteriaLanguage->add(new Criteria('itemtext.languageid', $xoopsConfig['language']));
$criteria->add($criteriaLanguage);
if (!empty($criteriaUser)) {
$criteria->add($criteriaUser, 'AND');
}
if (!empty($criteriaKeywords)) {
$criteria->add($criteriaKeywords, 'AND');
}
$criteria->setSort('item.weight');
$criteria->setOrder('ASC');
$sql .= ' ' . $criteria->renderWhere();
//$sql .= "GROUP BY parent." . $this->_key_field . "";
if ($criteria->getSort() != '') {
$sql .= ' ORDER BY ' . $criteria->getSort() . '
' . $criteria->getOrder();
}
//echo "<br />$sql<br />";
$result = $this->_db->query($sql, $limit, $offset);
// If no records from db, return empty array
if (!$result) {
return $ret;
}
// Add each returned record to the result array
while ($myrow = $this->_db->fetchArray($result)) {
$item['id'] = $myrow[$this->_key_field];
$item['title'] = $myrow[$this->_caption_field];
$item['categoryid'] = $myrow[$this->_parent_field];
$ret[] = $item;
unset($item);
}
return $ret;
}
示例11: getGrantedItems
/**
* Returns permissions for a certain type
*
* @param string $gpermName "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
*
* @return array
*/
public function getGrantedItems($gpermName)
{
static $items;
if (isset($items[$gpermName])) {
return $items[$gpermName];
}
$ret = array();
//Instead of calling groupperm handler and get objects, we will save some memory and do it our way
$criteria = new CriteriaCompo(new Criteria('gperm_name', $gpermName));
$criteria->add(new Criteria('gperm_modid', $this->publisher->getModule()->getVar('mid')));
//Get user's groups
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
$criteria2 = new CriteriaCompo();
foreach ($groups as $gid) {
$criteria2->add(new Criteria('gperm_groupid', $gid), 'OR');
}
$criteria->add($criteria2);
$db =& XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'SELECT gperm_itemid FROM ' . $db->prefix('group_permission');
$sql .= ' ' . $criteria->renderWhere();
$result = $db->query($sql, 0, 0);
while (($myrow = $db->fetchArray($result)) !== false) {
$ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid'];
}
$items[$gpermName] = $ret;
return $ret;
}
示例12: getLastPublishedByCat
/**
* @param array $status
*
* @return array
*/
public function getLastPublishedByCat($status = array(_PUBLISHER_STATUS_PUBLISHED))
{
$ret = array();
$cat = array();
$sql = "SELECT categoryid, MAX(datesub) as date FROM " . $this->db->prefix('publisher_items') . " WHERE status IN (" . implode(',', $status) . ") GROUP BY categoryid";
$result = $this->db->query($sql);
while ($row = $this->db->fetchArray($result)) {
$cat[$row['categoryid']] = $row['date'];
}
if (count($cat) == 0) {
return $ret;
}
$sql = "SELECT categoryid, itemid, title, short_url, uid, datesub FROM " . $this->db->prefix('publisher_items');
$criteriaBig = new CriteriaCompo();
foreach ($cat as $id => $date) {
$criteria = new CriteriaCompo(new Criteria('categoryid', $id));
$criteria->add(new Criteria('datesub', $date));
$criteriaBig->add($criteria, 'OR');
unset($criteria);
}
$sql .= " " . $criteriaBig->renderWhere();
$result = $this->db->query($sql);
while ($row = $this->db->fetchArray($result)) {
$item = new PublisherItem();
$item->assignVars($row);
$ret[$row['categoryid']] = $item;
unset($item);
}
return $ret;
}