當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XoopsBlock::assignVars方法代碼示例

本文整理匯總了PHP中XoopsBlock::assignVars方法的典型用法代碼示例。如果您正苦於以下問題:PHP XoopsBlock::assignVars方法的具體用法?PHP XoopsBlock::assignVars怎麽用?PHP XoopsBlock::assignVars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XoopsBlock的用法示例。


在下文中一共展示了XoopsBlock::assignVars方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: XoopsBlock

 /**
  * retrieve a specific {@link XoopsBlock}
  *
  * @see XoopsBlock
  * @param int $id bid of the block to retrieve
  * @return object XoopsBlock reference to the block
  **/
 function &get($id)
 {
     $id = (int) $id;
     if ($id > 0) {
         $sql = 'SELECT * FROM ' . $this->db->prefix('newblocks') . ' WHERE bid=' . $id;
         if (!($result = $this->db->query($sql))) {
             $ret = false;
             //< You may think this should be null. But this is the compatibility with X2.
             return $ret;
         }
         $numrows = $this->db->getRowsNum($result);
         if ($numrows == 1) {
             $block = new XoopsBlock();
             $block->assignVars($this->db->fetchArray($result));
             return $block;
         }
     }
     $ret = false;
     //< You may think this should be null. But this is the compatibility with X2.
     return $ret;
 }
開發者ID:nouphet,項目名稱:rata,代碼行數:28,代碼來源:block.php

示例2: getObjects

 /**
  * retrieve array of {@link XoopsBlock}s meeting certain conditions
  * @param  CriteriaElement $criteria  {@link CriteriaElement} with conditions for the blocks
  * @param  bool   $id_as_key should the blocks' bid be the key for the returned array?
  * @return array  {@link XoopsBlock}s matching the conditions
  **/
 public function getObjects(CriteriaElement $criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT DISTINCT(b.bid), b.* FROM ' . $this->db->prefix('newblocks') . ' b LEFT JOIN ' . $this->db->prefix('block_module_link') . ' l ON b.bid=l.block_id';
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $block = new XoopsBlock();
         $block->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $block;
         } else {
             $ret[$myrow['bid']] =& $block;
         }
         unset($block);
     }
     return $ret;
 }
開發者ID:geekwright,項目名稱:XoopsCore25,代碼行數:32,代碼來源:block.php

示例3: getDistinctObjects

 /**
  * retrieve array of {@link XoopsBlock}s meeting certain conditions
  * @param CriteriaElement|null $criteria {@link CriteriaElement} with conditions for the blocks
  * @param bool $id_as_key should the blocks' bid be the key for the returned array?
  * @return array {@link XoopsBlock}s matching the conditions
  **/
 public function getDistinctObjects(CriteriaElement $criteria = null, $id_as_key = false)
 {
     $ret = array();
     $qb = $this->db2->createXoopsQueryBuilder();
     $eb = $qb->expr();
     $qb->select('DISTINCT(b.bid)')->addSelect('b.*')->fromPrefix('newblocks', 'b')->leftJoinPrefix('b', 'block_module_link', 'l', $eb->eq('b.bid', 'l.block_id'));
     if (isset($criteria) && $criteria instanceof CriteriaElement) {
         $criteria->renderQb($qb);
     }
     $result = $qb->execute();
     if (!$result) {
         return $ret;
     }
     while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
         $block = new XoopsBlock();
         $block->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] = $block;
         } else {
             $ret[$myrow['bid']] = $block;
         }
         unset($block);
     }
     return $ret;
 }
開發者ID:RanLee,項目名稱:XoopsCore,代碼行數:31,代碼來源:block.php


注:本文中的XoopsBlock::assignVars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。