本文整理汇总了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;
}
示例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;
}
示例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;
}