当前位置: 首页>>代码示例>>PHP>>正文


PHP stdClass::set方法代码示例

本文整理汇总了PHP中stdClass::set方法的典型用法代码示例。如果您正苦于以下问题:PHP stdClass::set方法的具体用法?PHP stdClass::set怎么用?PHP stdClass::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stdClass的用法示例。


在下文中一共展示了stdClass::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: retrieve

 /**
  * Retrieve a value from the request (GET/POST/REQUEST)
  *
  * @param string $name name of the variable to be retrieved
  * @param string $type  type of the variable (see CRM_Utils_Type for details)
  * @param stdClass $store session scope where variable is stored
  * @param bool $abort is this variable required
  * @param mixed $default default value of the variable if not present
  * @param string $method where should we look for the variable
  *
  * @return mixed the value of the variable
  * @access public
  * @static
  */
 static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST')
 {
     // hack to detect stuff not yet converted to new style
     if (!is_string($type)) {
         CRM_Core_Error::backtrace();
         CRM_Core_Error::fatal(ts("Please convert retrieve call to use new function signature"));
     }
     $value = NULL;
     switch ($method) {
         case 'GET':
             $value = CRM_Utils_Array::value($name, $_GET);
             break;
         case 'POST':
             $value = CRM_Utils_Array::value($name, $_POST);
             break;
         default:
             $value = CRM_Utils_Array::value($name, $_REQUEST);
             break;
     }
     if (isset($value) && CRM_Utils_Type::validate($value, $type, $abort, $name) === NULL) {
         $value = NULL;
     }
     if (!isset($value) && $store) {
         $value = $store->get($name);
     }
     if (!isset($value) && $abort) {
         CRM_Core_Error::fatal(ts("Could not find valid value for %1", array(1 => $name)));
     }
     if (!isset($value) && $default) {
         $value = $default;
     }
     // minor hack for action
     if ($name == 'action' && is_string($value)) {
         $value = CRM_Core_Action::resolve($value);
     }
     if (isset($value) && $store) {
         $store->set($name, $value);
     }
     return $value;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:54,代码来源:Request.php

示例2: showArchiveSection

function showArchiveSection($id = NULL, $gid, &$access, $pop, $option)
{
    global $database, $mainframe, $mosConfig_offset;
    global $Itemid;
    $noauth = !$mainframe->getCfg('shownoauth');
    // Paramters
    $year = mosGetParam($_REQUEST, 'year', date('Y'));
    $month = mosGetParam($_REQUEST, 'month', date('m'));
    $params = new stdClass();
    if ($Itemid) {
        $menu = new mosMenu($database);
        $menu->load($Itemid);
        $params =& new mosParameters($menu->params);
    } else {
        $menu = "";
        $params =& new mosParameters('');
    }
    $params->set('intro_only', 1);
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby_sec', 'rdate');
    $orderby_pri = $params->def('orderby_pri', '');
    $order_sec = _orderby_sec($orderby_sec);
    $order_pri = _orderby_pri($orderby_pri);
    // used in query
    $where = _where(-1, $access, $noauth, $gid, $id, NULL, $year, $month);
    // checks to see if 'All Sections' options used
    if ($id == 0) {
        $check = '';
    } else {
        $check = 'AND a.sectionid = ' . $id;
    }
    // query to determine if there are any archived entries for the section
    $query = "SELECT a.id" . "\n FROM #__content as a" . "\n WHERE a.state = '-1'" . $check;
    $database->setQuery($query);
    $items = $database->loadObjectList();
    $archives = count($items);
    // Main Query
    $query = "SELECT a.*, ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, g.name AS groups" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . (count($where) ? "\n WHERE " . implode("\n AND ", $where) : '') . "\n AND s.access <= " . $gid . "\n ORDER BY " . $order_pri . $order_sec;
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    // initiate form
    echo '<form action="' . sefRelToAbs('index.php?option=' . $option . '&amp;task=archivesection&amp;id=' . $id . '&amp;Itemid=' . $Itemid) . '" method="post">';
    // Dynamic Page Title
    $mainframe->SetPageTitle($menu->name);
    if (!$archives) {
        // if no archives for category, hides search and outputs empty message
        echo '<br /><div align="center">' . _CATEGORY_ARCHIVE_EMPTY . '</div>';
    } else {
        BlogOutput($rows, $params, $gid, $access, $pop, $menu, 1);
    }
    echo '</form>';
}
开发者ID:cwcw,项目名称:cms,代码行数:54,代码来源:content.php


注:本文中的stdClass::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。