本文整理汇总了PHP中Memcached_DataObject类的典型用法代码示例。如果您正苦于以下问题:PHP Memcached_DataObject类的具体用法?PHP Memcached_DataObject怎么用?PHP Memcached_DataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Memcached_DataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNotices
function getNotices()
{
// @fixme there should be a common func for this
if (common_config('db', 'type') == 'pgsql') {
if (!empty($this->out->tag)) {
$tag = pg_escape_string($this->out->tag);
}
} else {
if (!empty($this->out->tag)) {
$tag = mysql_escape_string($this->out->tag);
}
}
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
$cutoff = sprintf("fave.modified > '%s'", common_sql_date(time() - common_config('popular', 'cutoff')));
$qry = "SELECT notice.*, {$weightexpr} as weight ";
if (isset($tag)) {
$qry .= 'FROM notice_tag, notice JOIN fave ON notice.id = fave.notice_id ' . "WHERE {$cutoff} and notice.id = notice_tag.notice_id and '{$tag}' = notice_tag.tag";
} else {
$qry .= 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . "WHERE {$cutoff}";
}
$qry .= ' GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . 'notice.rendered,notice.url,notice.created,notice.modified,' . 'notice.reply_to,notice.is_local,notice.source,notice.conversation, ' . 'notice.lat,notice.lon,location_id,location_ns,notice.repeat_of' . ' ORDER BY weight DESC';
$offset = 0;
$limit = NOTICES_PER_SECTION + 1;
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
$notice = Memcached_DataObject::cachedQuery('Notice', $qry, 1200);
return $notice;
}
示例2: getProfiles
function getProfiles()
{
$featured_nicks = common_config('nickname', 'featured');
if (!$featured_nicks) {
return null;
}
$quoted = array();
foreach ($featured_nicks as $nick) {
$quoted[] = "'{$nick}'";
}
$table = "user";
if (common_config('db', 'quote_identifiers')) {
$table = '"' . $table . '"';
}
$qry = 'SELECT profile.* ' . 'FROM profile JOIN ' . $table . ' on profile.id = ' . $table . '.id ' . 'WHERE ' . $table . '.nickname in (' . implode(',', $quoted) . ') ' . 'ORDER BY profile.created DESC ';
$limit = PROFILES_PER_SECTION + 1;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
return $profile;
}
示例3: getTags
function getTags()
{
$profile = Profile::current();
$keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id, $profile->id);
$tag = Memcached_DataObject::cacheGet($keypart);
if ($tag === false) {
$stream = new InboxNoticeStream($this->user, $profile);
$ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null);
if (empty($ids)) {
$tag = array();
} else {
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'WHERE notice.id in (' . implode(',', $ids) . ')' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$t = new Notice_tag();
$t->query($qry);
$tag = array();
while ($t->fetch()) {
$tag[] = clone $t;
}
}
Memcached_DataObject::cacheSet($keypart, $tag, 3600);
}
return new ArrayWrapper($tag);
}
示例4: getNotices
function getNotices($offset, $limit, $sinceId = null, $maxId = null)
{
$all = Memcached_DataObject::listGet('Notice', 'conversation', array($this->id));
$notices = $all[$this->id];
// Re-order in reverse-chron
usort($notices, array('RawConversationNoticeStream', '_reverseChron'));
// FIXME: handle since and max
$wanted = array_slice($notices, $offset, $limit);
return new ArrayWrapper($wanted);
}
示例5: getAttachments
/**
* Get the attachments for a particlar notice.
*
* @param int $post_id
* @return array of File objects
*/
static function getAttachments($post_id)
{
$file = new File();
$query = "select file.* from file join file_to_post on (file_id = file.id) where post_id = " . $file->escape($post_id);
$file = Memcached_DataObject::cachedQuery('File', $query);
$att = array();
while ($file->fetch()) {
$att[] = clone $file;
}
return $att;
}
示例6: getProfiles
function getProfiles()
{
$qry = 'SELECT profile.*, count(*) as value ' . 'FROM profile JOIN notice ON profile.id = notice.profile_id ' . (common_config('public', 'localonly') ? 'WHERE is_local = 1 ' : '') . 'GROUP BY profile.id,nickname,fullname,profileurl,homepage,bio,location,profile.created,profile.modified,textsearch ' . 'ORDER BY value DESC ';
$limit = PROFILES_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
return $profile;
}
示例7: getTags
function getTags()
{
$qry = $this->query();
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$profile_tag = Memcached_DataObject::cachedQuery('Profile_tag', sprintf($qry, $this->out->user->id));
return $profile_tag;
}
示例8: prefill
function prefill($notices)
{
// XXX: this should probably only be in the scoping one.
Notice::fillGroups($notices);
Notice::fillReplies($notices);
if (common_config('notice', 'hidespam')) {
$profiles = Notice::getProfiles($notices);
foreach ($profiles as $profile) {
$pids[] = $profile->id;
}
Memcached_DataObject::pivotGet('Profile_role', 'profile_id', $pids, array('role' => Profile_role::SILENCED));
}
}
示例9: getPeopletags
function getPeopletags()
{
$qry = 'SELECT profile_list.*, subscriber_count as value ' . 'FROM profile_list WHERE profile_list.private = false ' . 'ORDER BY value DESC ';
$limit = PEOPLETAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$peopletag = Memcached_DataObject::cachedQuery('Profile_list', $qry, 3600);
return $peopletag;
}
示例10: getGroups
function getGroups()
{
$qry = 'SELECT user_group.*, count(*) as value ' . 'FROM user_group JOIN group_member ' . 'ON user_group.id = group_member.group_id ' . 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' . 'ORDER BY value DESC ';
$limit = GROUPS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$group = Memcached_DataObject::cachedQuery('User_group', $qry, 3600);
return $group;
}
示例11: getTags
function getTags()
{
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'WHERE notice.profile_id = %d ' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$tag = Memcached_DataObject::cachedQuery('Notice_tag', sprintf($qry, $this->user->id), 3600);
return $tag;
}
示例12: getTags
function getTags()
{
if (common_config('db', 'type') == 'pgsql') {
$weightexpr = 'sum(exp(-extract(epoch from (now() - notice_tag.created)) / %s))';
} else {
$weightexpr = 'sum(exp(-(now() - notice_tag.created) / %s))';
}
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'JOIN group_inbox on group_inbox.notice_id = notice.id ' . 'WHERE group_inbox.group_id = %d ' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$tag = Memcached_DataObject::cachedQuery('Notice_tag', sprintf($qry, common_config('tag', 'dropoff'), $this->group->id), 3600);
return $tag;
}
示例13: getNotices
function getNotices()
{
if (common_config('db', 'type') == 'pgsql') {
$weightexpr = 'sum(exp(-extract(epoch from (now() - fave.modified)) / %s))';
} else {
$weightexpr = 'sum(exp(-(now() - fave.modified) / %s))';
}
$qry = 'SELECT notice.*, ' . $weightexpr . ' as weight ' . 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . 'GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . 'notice.rendered,notice.url,notice.created,notice.modified,' . 'notice.reply_to,notice.is_local,notice.source ' . 'ORDER BY weight DESC';
$offset = 0;
$limit = NOTICES_PER_SECTION + 1;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$notice = Memcached_DataObject::cachedQuery('Notice', sprintf($qry, common_config('popular', 'dropoff')), 1200);
return $notice;
}
示例14: showContent
/**
* Content area
*
* Shows the list of popular notices
*
* @return void
*/
function showContent()
{
$groupId = intval($this->group->id);
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
$cutoff = sprintf("fave.modified > '%s'", common_sql_date(time() - common_config('popular', 'cutoff')));
$qry = 'SELECT notice.*, ' . $weightexpr . ' as weight ' . 'FROM notice ' . "JOIN group_inbox ON notice.id = group_inbox.notice_id " . 'JOIN fave ON notice.id = fave.notice_id ' . "WHERE {$cutoff} AND group_id = {$groupId} " . 'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' . 'ORDER BY weight DESC';
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
$limit = NOTICES_PER_PAGE + 1;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$notice = Memcached_DataObject::cachedQuery('Notice', $qry, 600);
$nl = new NoticeList($notice, $this);
$cnt = $nl->show();
if ($cnt == 0) {
//$this->showEmptyList();
}
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'groupfavorited', array('nickname' => $this->group->nickname));
}
示例15: getTags
function getTags()
{
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-group.
$names = $this->group->getAliases();
$names = array_merge(array($this->group->nickname), $names);
// XXX This is dumb.
$quoted = array();
foreach ($names as $name) {
$quoted[] = "'{$name}'";
}
$namestring = implode(',', $quoted);
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'JOIN group_inbox on group_inbox.notice_id = notice.id ' . 'WHERE group_inbox.group_id = %d ' . 'AND notice_tag.tag not in (%s) ' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$tag = Memcached_DataObject::cachedQuery('Notice_tag', sprintf($qry, $this->group->id, $namestring), 3600);
return $tag;
}