本文整理汇总了PHP中Collection::addget方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::addget方法的具体用法?PHP Collection::addget怎么用?PHP Collection::addget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::addget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler_participants
protected function handler_participants(Collection $activities, $fields)
{
$res = XDB::iterator('SELECT id, participant
FROM activities_participants
WHERE id IN {?}', $activities->ids());
$users = new Collection('User');
$part = array();
while ($datas = $res->next()) {
$part[$datas['id']][] = $users->addget($datas['participant']);
}
foreach ($part as $key => $obj) {
$activities->get($key)->participants($obj);
}
$users->select($this->subs['participants']);
}
示例2: array
function handler_logs_sessions($page)
{
$iter = XDB::iterator('SELECT id, uid, host, ip, forward_ip, forward_host,
browser, suid, flags, start
FROM log_sessions
ORDER BY start DESC
LIMIT 50');
$sessions = array();
$users = new Collection('User');
while ($session = $iter->next()) {
$user = $users->addget($session['uid']);
$sessions[$session['id']] = array('user' => $user, 'host' => $session['host'], 'ip' => uint_to_ip($session['ip']), 'forward_host' => $session['forward_host'], 'forward_ip' => uint_to_ip($session['forward_ip']), 'browser' => $session['browser'], 'suid' => $session['suid'], 'flags' => $session['flags'], 'start' => new FrankizDateTime($session['start']));
}
$users->select(UserSelect::base());
$page->assign('title', "Logs des sessions");
$page->assign('sessions', $sessions);
$page->changeTpl('admin/logs_sessions.tpl');
}
示例3: all
public static function all()
{
$res = XDB::iterator('SELECT id, date, question, answer1, answer2, count1, count2, writer
FROM qdj
WHERE date!="0000-00-00" AND date<NOW()
ORDER BY date DESC');
$qdjs = new Collection('QDJ');
$users = new Collection('User');
while ($datas = $res->next()) {
$datas['writer'] = $users->addget($datas['writer']);
$datas['date'] = new FrankizDateTime($datas['date']);
$qdjs->addget($datas['id'])->fillFromArray($datas);
}
$users->select(UserSelect::base());
return $qdjs;
}
示例4: helper_collection
/**
* Select a collection from the database
*
* @param Collection $metas The objects to select
* @param string $field collection field
*/
protected function helper_collection(Collection $metas, $field)
{
// Retrieve link attributes
list($l_className, $table, $l_id, $id) = $this->schema->collectionType($field);
$_metas = array();
foreach ($metas as $meta) {
$_metas[$meta->id()] = new Collection($l_className);
}
// Get collection ids
$iter = XDB::iterRow("SELECT {$id}, {$l_id}\n FROM {$table}\n WHERE {$id} IN {?}", $metas->ids());
$linkeds = new Collection($l_className);
while (list($id, $l_id) = $iter->next()) {
$linked = $linkeds->addget($l_id);
$_metas[$id]->add($linked);
}
// Update metas
foreach ($metas as $meta) {
$meta->fillFromArray(array($field => $_metas[$meta->id()]));
}
if (!empty($this->subs[$field])) {
$linkeds->select($this->subs[$field]);
}
}
示例5: handler_castes
protected function handler_castes(Collection $users, $fields)
{
$_users = array();
foreach ($users as $user) {
$_users[$user->id()] = new Collection('Caste');
}
// Bootstrap session
$newuid = S::i('newuid');
if (S::has('newuid') && in_array($newuid, $users->ids())) {
$iter = XDB::iterRow('SELECT uid, cid
FROM castes_users
WHERE uid IN {?}', $users->ids());
} else {
$iter = XDB::iterRow('SELECT uid, cid
FROM castes_users
WHERE uid IN {?} AND
(visibility IN {?} OR uid IN {?})', $users->ids(), S::user()->visibleGids(), array($newuid, S::user()->id()));
}
$linkeds = new Collection('Caste');
while (list($uid, $cid) = $iter->next()) {
$linked = $linkeds->addget($cid);
$_users[$uid]->add($linked);
}
foreach ($users as $user) {
$user->fillFromArray(array('castes' => $_users[$user->id()]));
}
if (!empty($this->subs['castes'])) {
$linkeds->select($this->subs['castes']);
}
}
示例6: batchFrom
public static function batchFrom(array $mixed)
{
$collec = new Collection('Caste');
if (!empty($mixed)) {
$sql = array();
foreach ($mixed as $mix) {
$sql[] = XDB::format('(`group` = {?} AND rights = {?})', Group::toId($mix['group']), (string) $mix['rights']);
}
$iter = XDB::iterRow('SELECT cid, `group`, rights
FROM castes
WHERE ' . implode(' OR ', $sql));
$groups = new Collection('Group');
while (list($cid, $group, $rights) = $iter->next()) {
$group = $groups->addget($group);
$collec->add(new self(array('id' => $cid, 'group' => $group, 'rights' => new Rights($rights))));
}
}
return $collec;
}
示例7: batchSelect
public static function batchSelect(array $wikis, $options = null)
{
if (empty($wikis)) {
return;
}
$bits = self::optionsToBits($options);
$wikis = array_combine(self::toIds($wikis), $wikis);
$joins = array();
$cols = array();
if ($bits & self::SELECT_BASE) {
$cols['w'] = array('name', 'comments');
}
if ($bits & self::SELECT_COUNT || $bits & self::SELECT_VERSION) {
$cols[-1] = array('COUNT(wv.version) AS count');
$joins['wv'] = PlSqlJoin::left('wiki_version', '$ME.wid = w.wid');
}
if (!empty($cols)) {
$iter = XDB::iterator('SELECT w.wid AS id, ' . self::arrayToSqlCols($cols) . '
FROM wiki AS w
' . PlSqlJoin::formatJoins($joins, array()) . '
WHERE w.wid IN {?}
GROUP BY w.wid', array_keys($wikis));
while ($datas = $iter->next()) {
$wikis[$datas['id']]->fillFromArray($datas);
}
}
// Load last version
if ($bits & self::SELECT_VERSION) {
if (!isset($options[self::SELECT_VERSION])) {
$opts = array('versions' => array('last'));
} else {
$opts = $options[self::SELECT_VERSION];
}
$conds = array();
foreach ($wikis as $w) {
if ($w->versions == null) {
$w->versions = array();
}
$versions = array();
if (in_array('last', $opts['versions'])) {
$versions[] = $w->count();
}
foreach ($opts['versions'] as $version) {
if ($version != 'last') {
$versions[] = $version;
}
}
if (!empty($versions)) {
$conds[] = XDB::format('( wid = {?} AND version IN {?} )', $w->id(), $versions);
}
}
$iter = XDB::iterator('SELECT wid AS id, version, wrote, writer, content
FROM wiki_version
WHERE ' . implode(' OR ', $conds));
$writers = new Collection('User');
while ($datas = $iter->next()) {
$writer = $writers->addget($datas['writer']);
$wikis[$datas['id']]->versions[$datas['version']] = array('wrote' => $datas['wrote'], 'writer' => $writer, 'content' => $datas['content']);
}
if (isset($opts['options'])) {
$writers->select($opts['options']);
}
}
}