本文整理汇总了PHP中DBUtil::selectObjectArrayFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::selectObjectArrayFilter方法的具体用法?PHP DBUtil::selectObjectArrayFilter怎么用?PHP DBUtil::selectObjectArrayFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::selectObjectArrayFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Search plugin main function
**/
public function search($args)
{
if (!SecurityUtil::checkPermission('News::', '::', ACCESS_READ)) {
return true;
}
ModUtil::dbInfoLoad('Search');
$tables = DBUtil::getTables();
$newsColumn = $tables['news_column'];
$where = Search_Api_User::construct_where($args,
array($newsColumn['title'],
$newsColumn['hometext'],
$newsColumn['bodytext']),
$newsColumn['language']);
// Only search in published articles that are currently visible
$where .= " AND ({$newsColumn['published_status']} = '0')";
$date = DateUtil::getDatetime();
$where .= " AND ('$date' >= {$newsColumn['from']} AND ({$newsColumn['to']} IS NULL OR '$date' <= {$newsColumn['to']}))";
$sessionId = session_id();
ModUtil::loadApi('News', 'user');
$permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
$articles = DBUtil::selectObjectArrayFilter('news', $where, null, null, null, '', $permChecker, null);
foreach ($articles as $article)
{
$item = array(
'title' => $article['title'],
'text' => $article['hometext'],
'extra' => $article['sid'],
'created' => $article['from'],
'module' => 'News',
'session' => $sessionId
);
$insertResult = DBUtil::insertObject($item, 'search_result');
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load any articles.'));
}
}
return true;
}
示例2: search
//.........这里部分代码省略.........
// Load database stuff
ModUtil::dbInfoLoad('Search');
$dbtable = DBUtil::getTables();
$userId = (int)UserUtil::getVar('uid');
$searchTable = $dbtable['search_result'];
$searchColumn = $dbtable['search_result_column'];
// Create restriction on result table (so user only sees own results)
$userResultWhere = "$searchColumn[session] = '" . session_id() . "'";
// Do all the heavy database stuff on the first page only
if ($firstPage) {
// Clear current search result for current user - before showing the first page
// Clear also older searches from other users.
$dbDriverName = strtolower(Doctrine_Manager::getInstance()->getCurrentConnection()->getDriverName());
$where = $userResultWhere;
if ($dbDriverName == 'pgsql') {
$where .= " OR $searchColumn[found] + INTERVAL '8 HOUR' < NOW()";
} else {
$where .= " OR DATE_ADD($searchColumn[found], INTERVAL 8 HOUR) < NOW()";
}
DBUtil::deleteWhere('search_result', $where);
// get all the search plugins
$search_modules = ModUtil::apiFunc('Search', 'user', 'getallplugins');
// Ask active modules to find their items and put them into $searchTable for the current user
// At the same time convert modules list from numeric index to modname index
$searchModulesByName = array();
foreach ($search_modules as $mod) {
// check we've a valid search plugin
if (isset($mod['functions']) && (empty($active) || isset($active[$mod['title']]))) {
foreach ($mod['functions'] as $contenttype => $function) {
if (isset($modvar[$mod['title']])) {
$param = array_merge($vars, $modvar[$mod['title']]);
} else {
$param = $vars;
}
$searchModulesByName[$mod['name']] = $mod;
$ok = ModUtil::apiFunc($mod['title'], 'search', $function, $param);
if (!$ok) {
LogUtil::registerError($this->__f('Error! \'%1$s\' module returned false in search function \'%2$s\'.', array($mod['title'], $function)));
return System::redirect(ModUtil::url('Search', 'user', 'main'));
}
}
}
}
// Count number of found results
$resultCount = DBUtil::selectObjectCount('search_result', $userResultWhere);
SessionUtil::setVar('searchResultCount', $resultCount);
SessionUtil::setVar('searchModulesByName', $searchModulesByName);
} else {
$resultCount = SessionUtil::getVar('searchResultCount');
$searchModulesByName = SessionUtil::getVar('searchModulesByName');
}
// Fetch search result - do sorting and paging in database
// Figure out what to sort by
switch ($args['searchorder']) {
case 'alphabetical':
$sort = 'title';
break;
case 'oldest':
$sort = 'created';
break;
case 'newest':
$sort = 'created DESC';
break;
default:
$sort = 'title';
break;
}
// Get next N results from the current user's result set
// The "checker" object is used to:
// 1) do secondary access control (deprecated more or less)
// 2) let the modules add "url" to the found (and viewed) items
$checker = new search_result_checker($searchModulesByName);
$sqlResult = DBUtil::selectObjectArrayFilter('search_result', $userResultWhere, $sort,
$vars['startnum'] - 1, $vars['numlimit'], '',
$checker, null);
// add displayname of modules found
$cnt = count($sqlResult);
for ($i = 0; $i < $cnt; $i++) {
$modinfo = ModUtil::getInfoFromName($sqlResult[$i]['module']);
$sqlResult[$i]['displayname'] = $modinfo['displayname'];
}
$result = array(
'resultCount' => $resultCount,
'sqlResult' => $sqlResult
);
return $result;
}
示例3: getall
/**
* get all news items
* @author Mark West
* @return mixed array of items, or false on failure
*/
public function getall($args)
{
// Optional arguments.
if (!isset($args['status']) || (empty($args['status']) && $args['status'] !== 0)) {
$args['status'] = null;
}
if (!isset($args['startnum']) || empty($args['startnum'])) {
$args['startnum'] = 1;
}
if (!isset($args['numitems']) || empty($args['numitems'])) {
$args['numitems'] = -1;
}
if (!isset($args['ignoreml']) || !is_bool($args['ignoreml'])) {
$args['ignoreml'] = false;
}
if (!isset($args['language'])) {
$args['language'] = '';
}
if (!isset($args['filterbydate'])) {
$args['filterbydate'] = true;
}
if ((!empty($args['status']) && !is_numeric($args['status'])) ||
!is_numeric($args['startnum']) ||
!is_numeric($args['numitems'])) {
return LogUtil::registerArgsError();
}
// create a empty result set
$items = array();
// Security check
if (!SecurityUtil::checkPermission('News::', '::', ACCESS_OVERVIEW)) {
return $items;
}
$where = $this->generateWhere($args);
$tables = DBUtil::getTables();
$news_column = $tables['news_column'];
$orderby = '';
// Handle the sort order, if nothing requested use admin setting
if (!isset($args['order'])) {
$args['order'] = $this->getVar('storyorder');
switch ($args['order'])
{
case 0:
$order = 'sid';
break;
case 2:
$order = 'weight';
break;
case 1:
default:
$order = 'from';
}
} elseif (isset($news_column[$args['order']])) {
$order = $args['order'];
}
// if ordering is used also set the order direction, ascending/descending
if (!empty($order)) {
if (isset($args['orderdir']) && in_array(strtoupper($args['orderdir']), array('ASC', 'DESC'))) {
$orderby = $news_column[$order].' '.strtoupper($args['orderdir']);
} else {
$orderby = $news_column[$order].' DESC';
}
} elseif ($args['order'] == 'random') {
$orderby = 'RAND()';
}
// if sorted by weight add second ordering "from", since weight is not unique
if ($order == 'weight') {
$orderby .= ', ' . $news_column['from'] . ' DESC';
}
$permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
$objArray = DBUtil::selectObjectArrayFilter('news', $where, $orderby, $args['startnum'] - 1, $args['numitems'], '', $permChecker, $this->getCatFilter($args));
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($objArray === false) {
return LogUtil::registerError($this->__('Error! Could not load any articles.'));
}
// need to do this here as the category expansion code can't know the
// root category which we need to build the relative path component
if ($this->getVar('enablecategorization') && $objArray && isset($args['catregistry']) && $args['catregistry']) {
ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
}
// Return the items
return $objArray;
}
示例4: search
/**
* Perform a search.
*
* Parameters passed in the $args array:
* -------------------------------------
* ? $args['q'] ?.
* ? $args[?] ?.
*
* @param array $args All parameters passed to this function.
*
* @return bool True on success or null result, false on error.
*/
public function search($args)
{
ModUtil::dbInfoLoad('Search');
$table = DBUtil::getTables();
$pagestable = $table['pages'];
$pagescolumn = $table['pages_column'];
$searchTable = $table['search_result'];
$searchColumn = $table['search_result_column'];
$where = Search_Api_User::construct_where(
$args,
array(
$pagescolumn['title'],
$pagescolumn['content']
),
null
);
$sessionId = session_id();
/*
// define the permission filter to apply
$permFilter = array(array('realm' => 0,
'component_left' => 'Pages',
'component_right' => 'Page',
'instance_left' => 'title',
'instance_right' => 'pageid',
'level' => ACCESS_READ));
*/
// get the objects from the db
$permChecker = new pages_result_checker();
$objArray = DBUtil::selectObjectArrayFilter('pages', $where, 'pageid', 1, -1, '', $permChecker);
if ($objArray === false) {
return LogUtil::registerError($this->__('Error! Could not load any page.'));
}
$addcategorytitletopermalink = ModUtil::getVar('Pages', 'addcategorytitletopermalink');
$insertSql =
"INSERT INTO $searchTable
($searchColumn[title],
$searchColumn[text],
$searchColumn[extra],
$searchColumn[created],
$searchColumn[module],
$searchColumn[session])
VALUES ";
// Process the result set and insert into search result table
foreach ($objArray as $obj) {
if ($addcategorytitletopermalink) {
$extra = serialize(array(
'pageid' => $obj['pageid'],
'cat' => isset($obj['__CATEGORIES__']['Main']['name']) ? $obj['__CATEGORIES__']['Main']['name'] : null));
} else {
$extra = serialize(array('pageid' => $obj['pageid']));
}
$sql = $insertSql . '('
. '\'' . DataUtil::formatForStore($obj['title']) . '\', '
. '\'' . DataUtil::formatForStore($obj['content']) . '\', '
. '\'' . DataUtil::formatForStore($extra) . '\', '
. '\'' . DataUtil::formatForStore($obj['cr_date']) . '\', '
. '\'' . 'Pages' . '\', '
. '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load any page.'));
}
}
return true;
}
示例5: search
/**
* Search plugin main function
**/
public function search($args)
{
// Permission check
$this->throwForbiddenUnless(SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_READ), LogUtil::getErrorMsgPermission());
ModUtil::dbInfoLoad('Search');
$ztable = DBUtil::getTables();
$addresstable = $ztable['addressbook_address'];
$addresscolumn = $ztable['addressbook_address_column'];
$searchTable = $ztable['search_result'];
$searchColumn = $ztable['search_result_column'];
$searchcols = array($addresscolumn['lname'], $addresscolumn['fname'], $addresscolumn['company'], $addresscolumn['city'], $addresscolumn['zip'], $addresscolumn['address1'], $addresscolumn['address2'], $addresscolumn['state'], $addresscolumn['country'], $addresscolumn['contact_1'], $addresscolumn['contact_2'], $addresscolumn['contact_3'], $addresscolumn['contact_4'], $addresscolumn['contact_5']);
$cusfields = DBUtil::selectFieldArray('addressbook_customfields', 'id');
// Get user id
if (UserUtil::isLoggedIn()) {
$user_id = UserUtil::getVar('uid');
} else {
$user_id = 0;
}
for ($i = 0; $i < count($cusfields); $i++) {
$colname = 'custom_' . $cusfields[$i];
array_push($searchcols, $addresscolumn[$colname]);
}
$where = search_construct_where($args, $searchcols);
// admin always sees all records but favorites
if (SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) {
$where .= " AND ({$addresscolumn['user_id']} IS NOT NULL)";
} else {
// global protect - users see only their own records (admin sees all)
if (ModUtil::getVar('AddressBook', 'globalprotect') == 1 && !SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) {
$where .= " AND ({$addresscolumn['user_id']}={$user_id})";
} else {
// if private = 1, show only private records
if ($private == 1) {
$where .= " AND ({$addresscolumn['user_id']}={$user_id} AND {$addresscolumn['private']} = 1)";
} else {
// if private = 0, show all records
$where .= " AND (({$addresscolumn['private']} = 0) OR ({$addresscolumn['user_id']}={$user_id} AND {$addresscolumn['private']} = 1))";
}
}
}
$sessionId = session_id();
$insertSql = "INSERT INTO {$searchTable}\n ({$searchColumn['title']},\n {$searchColumn['text']},\n {$searchColumn['extra']},\n {$searchColumn['module']},\n {$searchColumn['created']},\n {$searchColumn['session']})\n VALUES ";
ModUtil::loadApi('AddressBook', 'user');
if (ModUtil::getVar('AddressBook', 'addressbooktype') == 1) {
$sort = "sortname DESC,sortcompany DESC";
} else {
$sort = "sortcompany DESC,sortname DESC";
}
$permChecker = new addressbook_result_checker();
//$addresses = DBUtil::selectObjectArray('addressbook_address', $where, null, null, '', $permChecker, null);
$addresses = DBUtil::selectObjectArrayFilter('addressbook_address', $where, null, null, null, '', $permChecker, null);
foreach ($addresses as $address) {
$line_1 = $address['fname'] . " " . $address['lname'];
if (empty($line_1)) {
$line_1 = $address['company'];
} else {
if (!empty($address['company'])) {
$line_1 .= " [" . $address['company'] . "]";
}
}
if (ModUtil::getVar('AddressBook', 'zipbeforecity') == 1) {
$line_2 = $address['zip'] . " " . $address['city'];
} else {
$line_2 = $address['city'] . " " . $address['zip'];
}
$sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($line_1) . '\', ' . '\'' . DataUtil::formatForStore($line_2) . '\', ' . '\'' . DataUtil::formatForStore($address['id']) . '\', ' . '\'' . 'AddressBook' . '\', ' . '\'' . DataUtil::formatForStore($address['cr_date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load addresses.'));
}
}
return true;
}