本文整理汇总了PHP中DBUtil::selectObjectArray方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::selectObjectArray方法的具体用法?PHP DBUtil::selectObjectArray怎么用?PHP DBUtil::selectObjectArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::selectObjectArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Update the IWdocmanager module
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function upgrade($oldversion) {
$table = DBUtil::getTables();
switch ($oldversion) {
case '0.0.1';
$table = DBUtil::getTables();
$c = $table['IWdocmanager_column'];
$c1 = $table['IWdocmanager_categories_column'];
// used in agora module upgrade in order to calc the number of document in each category
$categories = DBUtil::selectObjectArray('IWdocmanager_categories', '', '', '-1', '-1', 'categoryId');
foreach ($categories as $category) {
$where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 1 AND $c[versioned] <= 0";
$number = DBUtil::selectObjectCount('IWdocmanager', $where);
$where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 0 AND $c[versioned] <= 0";
$number1 = DBUtil::selectObjectCount('IWdocmanager', $where);
$where = "$c1[categoryId] = $category[categoryId]";
$item = array('nDocuments' => $number,
'nDocumentsNV' => $number1
);
DBUtil::updateObject($item, 'IWdocmanager_categories', $where);
}
case '1.0.0':
// future versions
}
return true;
}
示例2: getall
/**
* Gets all the items created in the menu
* @author: Albert Pérez Monfort (aperezm@xtec.cat)
* @param: args id_parent
* @return: And array with the items information
*/
public function getall($args) {
// Security check
if (!SecurityUtil::checkPermission('IWmenu::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
extract($args);
// Needed arguments.
if (isset($id_parent))
$id = $id_parent;
(!isset($id)) ? $id_parent = 0 : $id_parent = $id;
$active = (isset($active)) ? " AND active=$active " : "";
$pntable = DBUtil::getTables();
$c = $pntable['IWmenu_column'];
$where = ($id_parent == '-1') ? "$active" : "$c[id_parent]=$id_parent $active";
$orderby = "$c[iorder]";
// get the objects from the db
$items = DBUtil::selectObjectArray('IWmenu', $where, $orderby, '-1', '-1', 'mid');
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($items === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
// Return the items
return $items;
}
示例3: getModuleConfig
public function getModuleConfig($args)
{
if (!isset($args['modulename'])) {
$args['modulename'] = ModUtil::getName();
}
$modconfig = array();
if ($args['modulename'] == 'list') {
$modconfig = DBUtil::selectObjectArray('scribite', '', 'modname');
} else {
$dbtables = DBUtil::getTables();
$scribitecolumn = $dbtables['scribite_column'];
$where = "{$scribitecolumn['modname']} = '" . $args['modulename'] . "'";
$item = DBUtil::selectObjectArray('scribite', $where);
if ($item == false) {
return;
}
$modconfig['mid'] = $item[0]['mid'];
$modconfig['modulename'] = $item[0]['modname'];
if (!is_int($item[0]['modfuncs'])) {
$modconfig['modfuncs'] = unserialize($item[0]['modfuncs']);
}
if (!is_int($item[0]['modareas'])) {
$modconfig['modareas'] = unserialize($item[0]['modareas']);
}
$modconfig['modeditor'] = $item[0]['modeditor'];
}
return $modconfig;
}
示例4: search
/**
* Search
*
* do the actual search and display the results
*
* @return output the search results
*/
public function search($args)
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
return true;
}
$minlen = 3;
$maxlen = 30;
if (strlen($args['q']) < $minlen || strlen($args['q']) > $maxlen) {
return LogUtil::registerStatus($this->__f('The comments can only be searched for words that are longer than %1$s and less than %2$s characters!', array($minlen, $maxlen)));
}
ModUtil::dbInfoLoad('Search');
$tables = DBUtil::getTables();
// ezcomments tables
$ezcommentstable = $tables['EZComments'];
$ezcommentscolumn = $tables['EZComments_column'];
// our own tables
$searchTable = $tables['search_result'];
$searchColumn = $tables['search_result_column'];
// where
$where = Search_Api_User::construct_where($args, array($ezcommentscolumn['subject'], $ezcommentscolumn['comment']));
$where .= " AND " . $ezcommentscolumn['url'] . " != ''";
$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\n ";
$comments = DBUtil::selectObjectArray('EZComments', $where);
foreach ($comments as $comment) {
$sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($comment['subject']) . '\', ' . '\'' . DataUtil::formatForStore($comment['comment']) . '\', ' . '\'' . DataUtil::formatForStore($comment['url']) . '\', ' . '\'' . 'EZComments' . '\', ' . '\'' . DataUtil::formatForStore($comment['date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
}
return true;
}
示例5: getall
/**
* Return all the references that have been created
*
* @param int $args['starnum'] (optional) first item to return
* @param int $args['numitems'] (optional) number if items to return
* @return array array of items, or false on failure
*/
public function getall($args) {
$items = array();
// Security check
if (!SecurityUtil::checkPermission('IWwebbox::', '::', ACCESS_ADMIN)) {
return $items;
}
// Optional arguments.
if (!isset($args['startnum']) || !is_numeric($args['startnum'])) {
$args['startnum'] = 1;
}
if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
$args['numitems'] = -1;
}
// get the objects from the db
$items = DBUtil::selectObjectArray('IWwebbox', '', 'ref', $args['startnum'] - 1, $args['numitems'], '', '', '');
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($items === false) {
return LogUtil::registerError(__('Error! Could not load items.'));
}
// Return the items
return $items;
}
示例6: get_sense_grup
public function get_sense_grup() {
$users = DBUtil::selectObjectArray('users', '', '', -1, -1, 'uid');
// Check for a DB error
if ($users === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
// get all users that are in any group
$allUsersWithGroup = DBUtil::selectObjectArray('group_membership', '', '', -1, -1, 'uid');
if ($allUsersWithGroup === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
$diff = array_diff_key($users, $allUsersWithGroup);
$usersList = '$$';
$registres = array();
if (count($diff) > 0) {
foreach ($diff as $user) {
$usersList .= $user['uid'] . '$$';
}
//get all users information
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$usersInfo = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('sv' => $sv,
'list' => $usersList,
'info' => 'ccn'));
foreach ($usersInfo as $key => $value) {
$registres[] = array('name' => $value,
'id' => $key);
}
}
return $registres;
}
示例7: search
/**
* Search plugin main function
**/
public function search($args)
{
if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_READ)) {
return true;
}
ModUtil::dbInfoLoad('Search');
$pntable = DBUtil::getTables();
$feedscolumn = $pntable['feeds_column'];
$searchTable = $pntable['search_result'];
$searchColumn = $pntable['search_result_column'];
$where = search_construct_where($args,
array($feedscolumn['name']),
null);
$sessionId = session_id();
// define the permission filter to apply
$permFilter = array(array('realm' => 0,
'component_left' => 'Feeds',
'instance_left' => 'fid',
'instance_right' => '',
'level' => ACCESS_READ));
// get the result set
$objArray = DBUtil::selectObjectArray('feeds', $where, 'fid', 1, -1, '', $permFilter);
if ($objArray === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
$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) {
$sql = $insertSql . '('
. '\'' . DataUtil::formatForStore($obj['name']) . '\', '
. '\'' . '\', '
. '\'' . DataUtil::formatForStore($obj['fid']) . '\', '
. '\'' . DataUtil::formatForStore($obj['cr_date']) . '\', '
. '\'' . 'Feeds' . '\', '
. '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError(__('Error! Could not load items.', $dom));
}
}
return true;
}
示例8: getDeletedPages
public function getDeletedPages($args)
{
$offset = array_key_exists('offset', $args) ? $args['offset'] : 0;
$pageSize = array_key_exists('pageSize', $args) ? $args['pageSize'] : 20;
$tables = DBUtil::getTables();
$historyColumn = $tables['content_history_column'];
$pageColumn = $tables['content_page_column'];
$where = "{$historyColumn['pageId']} not in (select {$pageColumn['id']} from {$tables['content_page']}) and {$historyColumn['action']} = '_CONTENT_HISTORYPAGEDELETED'";
/* related to delayed translation */
return DBUtil::selectObjectArray('content_history', $where, 'date DESC', $offset, $pageSize);
// TODO: distinct
}
示例9: mediashare_sourcesapi_getSources
function mediashare_sourcesapi_getSources($args)
{
$dom = ZLanguage::getModuleDomain('mediashare');
$pntable = pnDBGetTables();
$sourcesTable = $pntable['mediashare_sources'];
$sourcesColumn = $pntable['mediashare_sources_column'];
$where = "";
if ($args['active']) {
$where = "WHERE {$sourcesColumn['active']} = '" . DataUtil::formatForStore($args['active']) . "'";
}
$result = DBUtil::selectObjectArray('mediashare_sources', $where);
if ($result === false) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.getSources', 'Could not retrieve the sources.'), $dom));
}
return $result;
}
示例10: getall_horari
public function getall_horari($args) {
$mdid = FormUtil::getPassedValue('mdid', isset($args['mdid']) ? $args['mdid'] : null, 'GET');
$registres = array();
if (!SecurityUtil::checkPermission('IWtimeframes::', '::', ACCESS_READ)) {
return $registres;
}
$orderby = "start";
$items = DBUtil::selectObjectArray('IWtimeframes', 'mdid=' . $mdid, $orderby);
foreach ($items as $item) {
$registres[] = array('hid' => $item['hid'],
'hora' => date('H:i', strtotime($item['start'])) . " - " . date('H:i', strtotime($item['end'])),
'descriu' => $item['descriu']);
}
//Retornem la matriu plena de registres
return $registres;
}
示例11: EZComments_migrateapi_pnProfile
/**
* Do the migration
*
* With this function, the actual migration is done.
*
* @return boolean true on sucessful migration, false else
*/
function EZComments_migrateapi_pnProfile()
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
return LogUtil::registerError('pnProfile comments migration: Not Admin');
}
$columnArray = array('id', 'modname', 'objectid');
$comments = DBUtil::selectObjectArray('EZComments', '', '', -1, -1, '', null, null, $columnArray);
$counter = 0;
foreach ($comments as $comment) {
if ($comment['modname'] == 'pnProfile') {
$comment['modname'] = 'MyProfile';
$comment['url'] = ModUtil::url('MyProfile', 'user', 'display', array('uid' => $comment['objectid']));
$comment['owneruid'] = $comment['objectid'];
if (DBUtil::updateObject($comment, 'EZComments')) {
$counter++;
}
}
}
return LogUtil::registerStatus("Updated / migrated: {$counter} comments from pnProfile to MyProfile, the successor of pnProfile");
}
示例12: getusersbyavatar
/**
* get all users that use the given avatar
*
*@params $args['avatar'] string the avatar name
*/
public function getusersbyavatar($args)
{
if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
$users = array();
if (!isset($args['avatar']) || empty($args['avatar'])) {
return $users;
}
$ztables = DBUtil::getTables();
$userdatacolumn = $ztables['objectdata_attributes_column'];
if ($args['avatar'] == 'blank.gif') {
$where = $userdatacolumn['attribute_name'] . '="avatar" AND (' . $userdatacolumn['value'] . '="' . DataUtil::formatForStore($args['avatar']) . '" OR ' . $userdatacolumn['value'] . '="")';
} else {
$where = $userdatacolumn['attribute_name'] . '="avatar" AND ' . $userdatacolumn['value'] . '="' . DataUtil::formatForStore($args['avatar']) . '"';
}
$avatarusers = DBUtil::selectObjectArray('objectdata_attributes', $where);
foreach ($avatarusers as $avataruser) {
$users[$avataruser['id']] = UserUtil::getVar('uname', $avataruser['object_id']);
}
return $users;
}
示例13: getUsers
/**
* Performs a user search based on the user name fragment entered so far.
*
* Parameters passed via POST:
* ---------------------------
* string fragment A partial user name entered by the user.
*
* @return string Zikula_Response_Ajax_Plain with list of users matching the criteria.
*/
public function getUsers()
{
$this->checkAjaxToken();
$view = Zikula_View::getInstance($this->name);
if (SecurityUtil::checkPermission('Users::', '::', ACCESS_MODERATE)) {
$fragment = $this->request->query->get('fragment', $this->request->request->get('fragment'));
ModUtil::dbInfoLoad($this->name);
$tables = DBUtil::getTables();
$usersColumn = $tables['users_column'];
$where = 'WHERE ' . $usersColumn['uname'] . ' REGEXP \'(' . DataUtil::formatForStore($fragment) . ')\'';
$results = DBUtil::selectObjectArray('users', $where);
$view->assign('results', $results);
}
$output = $view->fetch('users_ajax_getusers.tpl');
return new Zikula_Response_Ajax_Plain($output);
}
示例14: getall
/**
* get all pages
*
* @param array $args Arguments array.
*
* @return mixed array of items, or false on failure
*/
public function getall($args)
{
// Optional arguments.
if (!isset($args['startnum']) || empty($args['startnum'])) {
$args['startnum'] = 0;
}
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'] = null;
}
if (!isset($args['category'])) {
$args['category'] = null;
}
if (!is_numeric($args['startnum']) || !is_numeric($args['numitems'])) {
return LogUtil::registerArgsError();
}
// Security check
if (!SecurityUtil::checkPermission('Pages::', '::', ACCESS_READ)) {
return array();
}
$catFilter = array();
if (isset($args['category']) && !empty($args['category'])) {
if (is_array($args['category'])) {
$catFilter = $args['category'];
} elseif (isset($args['property'])) {
$property = $args['property'];
$catFilter[$property] = $args['category'];
}
$catFilter['__META__'] = array('module' => 'Pages');
} elseif (isset($args['catfilter'])) {
$catFilter = $args['catfilter'];
}
// populate an array with each part of the where clause and then implode the array if there is a need.
// credit to Jorg Napp for this technique - markwest
$table = DBUtil::getTables();
$pagescolumn = $table['pages_column'];
$queryargs = array();
if (System::getVar('multilingual') == 1 && !$args['ignoreml'] && $args['language']) {
$queryargs[] = '(' . $pagescolumn['language'] . ' = "' . DataUtil::formatForStore($args['language']) . '"'
.' OR ' . $pagescolumn['language'] . ' = "")';
}
$where = null;
if (count($queryargs) > 0) {
$where = ' WHERE ' . implode(' AND ', $queryargs);
}
// define the permission filter to apply
$permFilter = array();
$permFilter[] = array('component_left' => 'Pages',
'instance_left' => 'title',
'instance_right' => 'pageid',
'level' => ACCESS_READ);
$orderby = $pagescolumn['pageid'];
if (isset($args['order']) && !empty($args['order'])) {
$orderby = $pagescolumn[strtolower($args['order'])];
}
$orderdir = 'DESC';
if (isset($args['orderdir']) && !empty($args['orderdir'])) {
$orderdir = $args['orderdir'];
}
$orderby = $orderby . ' ' . $orderdir;
// get the objects from the db
$objArray = DBUtil::selectObjectArray(
'pages',
$where,
$orderby,
$args['startnum']-1,
$args['numitems'],
'',
$permFilter,
$catFilter
);
// 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 page.'));
}
// 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
//.........这里部分代码省略.........
示例15: updateObjectAttributes
/**
* Update the attributes for the given objects.
*
* @param array $obj The object whose attributes we wish to store.
* @param string $type The type of the given object.
* @param string $idcolumn The idcolumn of the object (optional) (default='id').
* @param boolean $force Flag to force the attribute update.
*
* @todo check if the function can supersede storeObjectAttributes().
*
* @return boolean true/false on success/failure.
*/
public static function updateObjectAttributes($obj, $type, $idcolumn = 'id', $force = false)
{
if (!$obj) {
throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('object', __CLASS__ . '::' . __FUNCTION__)));
}
if (!$type) {
throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('type', __CLASS__ . '::' . __FUNCTION__)));
}
if (!isset($obj['__ATTRIBUTES__']) || !is_array($obj['__ATTRIBUTES__'])) {
return false;
}
$objID = $obj[$idcolumn];
if (!$objID) {
throw new \Exception(__f('Unable to determine a valid ID in object [%1$s, %2$s]', array($type, $idcolumn)));
}
$dbtables = DBUtil::getTables();
$column = $dbtables['objectdata_attributes_column'];
// select all attributes so that we can check if we have to update or insert
// this will be an assoc array of attributes with 'attribute_name' as key
$where = 'WHERE ' . $column['object_type'] . '=\'' . DataUtil::formatForStore($type) . '\'
AND ' . $column['object_id'] . '=\'' . DataUtil::formatForStore($objID) . '\'';
$attrs = DBUtil::selectObjectArray('objectdata_attributes', $where, null, null, null, 'attribute_name');
// process all the attribute fields
foreach ($obj['__ATTRIBUTES__'] as $k => $v) {
// only fill empty attributes when force
if ($force || strlen($v)) {
if (!array_key_exists($k, $attrs)) {
$newobj['attribute_name'] = $k;
$newobj['object_id'] = $objID;
$newobj['object_type'] = $type;
$newobj['value'] = $v;
DBUtil::insertObject($newobj, 'objectdata_attributes');
} else {
$attrs[$k]['value'] = $v;
DBUtil::updateObject($attrs[$k], 'objectdata_attributes');
}
}
}
if (isset($dbtables[$type])) {
DBUtil::flushCache($type);
}
return true;
}