本文整理汇总了PHP中Notice::whereAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::whereAdd方法的具体用法?PHP Notice::whereAdd怎么用?PHP Notice::whereAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::whereAdd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNoticeIds
function getNoticeIds($offset, $limit, $since_id = null, $max_id = null)
{
$notice = new Notice();
// SELECT
$notice->selectAdd();
$notice->selectAdd('id');
// WHERE
$notice->conversation = $this->id;
if (!empty($since_id)) {
$notice->whereAdd(sprintf('notice.id > %d', $since_id));
}
if (!empty($max_id)) {
$notice->whereAdd(sprintf('notice.id <= %d', $max_id));
}
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (!empty($this->selectVerbs)) {
$notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
// ORDER BY
// currently imitates the previously used "_reverseChron" sorting
$notice->orderBy('notice.created DESC');
$notice->find();
return $notice->fetchAll('id');
}
示例2: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (common_config('public', 'localonly')) {
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
} else {
// -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !=' . Notice::GATEWAY);
}
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
$strSql = sprintf('(content_type=%d or content_type=%d)', NOTICE::CONTENT_TYPE_POST, NOTICE::CONTENT_TYPE_REPEAT);
$strSql = sprintf('(content_type in (%d,%d,%d,%d))', NOTICE::CONTENT_TYPE_REPEAT, NOTICE::CONTENT_TYPE_REPEAT | NOTICE::CONTENT_TYPE_MENTIONS, NOTICE::CONTENT_TYPE_POST, NOTICE::CONTENT_TYPE_POST | NOTICE::CONTENT_TYPE_MENTIONS);
$notice->whereAdd($strSql);
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例3: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (common_config('public', 'localonly')) {
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
} else {
// -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !=' . Notice::GATEWAY);
}
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例4: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
$notice->whereAdd('is_local =' . Notice::REMOTE);
// -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !=' . Notice::GATEWAY);
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
if (!empty($this->selectVerbs)) {
$notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例5: getNotices
function getNotices($y, $m, $d, $i)
{
$n = Notice::cacheGet("sitemap:notice:{$y}:{$m}:{$d}:{$i}");
if ($n === false) {
$notice = new Notice();
$begindt = sprintf('%04d-%02d-%02d 00:00:00', $y, $m, $d);
// XXX: estimates 1d == 24h, which screws up days
// with leap seconds (1d == 24h + 1s). Thankfully they're
// few and far between.
$theend = strtotime($begindt) + 24 * 60 * 60;
$enddt = common_sql_date($theend);
$notice->selectAdd();
$notice->selectAdd('id, created');
$notice->whereAdd("created >= '{$begindt}'");
$notice->whereAdd("created < '{$enddt}'");
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
$notice->orderBy('created');
$offset = ($i - 1) * SitemapPlugin::NOTICES_PER_MAP;
$limit = SitemapPlugin::NOTICES_PER_MAP;
$notice->limit($offset, $limit);
$notice->find();
$n = array();
while ($notice->fetch()) {
$n[] = array($notice->id, $notice->created);
}
$c = Cache::instance();
if (!empty($c)) {
$c->set(Cache::key("sitemap:notice:{$y}:{$m}:{$d}:{$i}"), $n, Cache::COMPRESSED, time() > $theend ? time() + 90 * 24 * 60 * 60 : time() + 5 * 60);
}
}
return $n;
}
示例6: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
// This feed always gives only local activities.
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
if (!empty($this->selectVerbs)) {
$notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例7: getStreamByIds
static function getStreamByIds($ids)
{
$cache = Cache::instance();
if (!empty($cache)) {
$notices = array();
foreach ($ids as $id) {
$n = Notice::staticGet('id', $id);
if (!empty($n)) {
$notices[] = $n;
}
}
return new ArrayWrapper($notices);
} else {
$notice = new Notice();
if (empty($ids)) {
//if no IDs requested, just return the notice object
return $notice;
}
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
$notice->find();
$temp = array();
while ($notice->fetch()) {
$temp[$notice->id] = clone $notice;
}
$wrapped = array();
foreach ($ids as $id) {
if (array_key_exists($id, $temp)) {
$wrapped[] = $temp[$id];
}
}
return new ArrayWrapper($wrapped);
}
}
示例8: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
$convId = $this->trimmed('id');
if (empty($convId)) {
// TRANS: Client exception thrown when no conversation ID is given.
throw new ClientException(_('No conversation ID.'));
}
$this->conversation = Conversation::staticGet('id', $convId);
if (empty($this->conversation)) {
// TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
$this->clientError(_('No conversation ID found'), 404);
return false;
}
$profile = Profile::current();
$stream = new ConversationNoticeStream($convId, $profile);
$notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
$this->notices = $notice->fetchAll();
$originalConversation = new Notice();
$originalConversation->whereAdd('conversation=' . $convId);
$originalConversation->limit(1);
$originalConversation->orderBy('created');
$originalConversation->find();
if ($originalConversation->fetch()) {
$this->originalNotice = $originalConversation;
}
return true;
}
示例9: getNotices
function getNotices()
{
$notice = new Notice();
$notice->joinAdd(array('id', 'file_to_post:post_id'));
$notice->whereAdd(sprintf('file_to_post.file_id = %d', $this->out->attachment->id));
$notice->orderBy('created desc');
$notice->selectAdd('post_id as id');
$notice->find();
return $notice;
}
示例10: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
$notice->selectAdd('id');
$notice->orderBy('id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
$notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !=' . Notice::GATEWAY);
$notice->whereAdd('repeat_of IS NULL');
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例11: onEndUpgrade
function onEndUpgrade()
{
// Version 0.9.x of the plugin didn't stamp notices
// with verb and object-type (for obvious reasons). Update
// those notices here.
$notice = new Notice();
$notice->whereAdd('exists (select uri from bookmark where bookmark.uri = notice.uri)');
$notice->whereAdd('((object_type is null) or (object_type = "' . ActivityObject::NOTE . '"))');
$notice->find();
while ($notice->fetch()) {
$original = clone $notice;
$notice->verb = ActivityVerb::POST;
$notice->object_type = ActivityObject::BOOKMARK;
$notice->update($original);
}
}
示例12: checkDupes
static function checkDupes($profile_id, $content)
{
$profile = Profile::getKV($profile_id);
if (!$profile instanceof Profile) {
return false;
}
$notice = $profile->getNotices(0, CachingNoticeStream::CACHE_WINDOW);
if (!empty($notice)) {
$last = 0;
while ($notice->fetch()) {
if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) {
return true;
} else {
if ($notice->content == $content) {
return false;
}
}
}
}
// If we get here, oldest item in cache window is not
// old enough for dupe limit; do direct check against DB
$notice = new Notice();
$notice->profile_id = $profile_id;
$notice->content = $content;
$threshold = common_sql_date(time() - common_config('site', 'dupelimit'));
$notice->whereAdd(sprintf("created > '%s'", $notice->escape($threshold)));
$cnt = $notice->count();
return $cnt == 0;
}
示例13: getNoticesBetween
/**
*
* @param int $start unix timestamp for earliest
* @param int $end unix timestamp for latest
* @return array of Notice objects
*/
function getNoticesBetween($start = 0, $end = 0)
{
$notices = array();
$notice = new Notice();
$notice->profile_id = $this->user->id;
// Only stuff after $this->after
if (!empty($this->after)) {
if ($start) {
$start = max($start, $this->after);
}
if ($end) {
$end = max($end, $this->after);
}
}
if ($start) {
$tsstart = common_sql_date($start);
$notice->whereAdd("created >= '{$tsstart}'");
}
if ($end) {
$tsend = common_sql_date($end);
$notice->whereAdd("created < '{$tsend}'");
}
$notice->orderBy('created DESC');
if ($notice->find()) {
while ($notice->fetch()) {
$notices[] = clone $notice;
}
}
return $notices;
}
示例14: Notice
function _repeatedByMeDirect($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->profile_id = $this->id;
$notice->whereAdd('repeat_of IS NOT NULL');
$notice->orderBy('id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if ($since_id != 0) {
$notice->whereAdd('id > ' . $since_id);
}
if ($max_id != 0) {
$notice->whereAdd('id <= ' . $max_id);
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例15: Notice
function _conversationStreamDirect($id, $offset = 0, $limit = 20, $since_id = 0, $max_id = 0)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->conversation = $id;
$notice->orderBy('id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if ($since_id != 0) {
$notice->whereAdd('id > ' . $since_id);
}
if ($max_id != 0) {
$notice->whereAdd('id <= ' . $max_id);
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}