当前位置: 首页>>代码示例>>PHP>>正文


PHP common_sql_now函数代码示例

本文整理汇总了PHP中common_sql_now函数的典型用法代码示例。如果您正苦于以下问题:PHP common_sql_now函数的具体用法?PHP common_sql_now怎么用?PHP common_sql_now使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了common_sql_now函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_twitter_user

function add_twitter_user($twitter_id, $screen_name)
{
    // Clear out any bad old foreign_users with the new user's legit URL
    // This can happen when users move around or fakester accounts get
    // repoed, and things like that.
    $luser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
    if (!empty($luser)) {
        $result = $luser->delete();
        if ($result != false) {
            common_log(LOG_INFO, "Twitter bridge - removed old Twitter user: {$screen_name} ({$twitter_id}).");
        }
    }
    $fuser = new Foreign_user();
    $fuser->nickname = $screen_name;
    $fuser->uri = 'http://twitter.com/' . $screen_name;
    $fuser->id = $twitter_id;
    $fuser->service = TWITTER_SERVICE;
    $fuser->created = common_sql_now();
    $result = $fuser->insert();
    if (empty($result)) {
        common_log(LOG_WARNING, "Twitter bridge - failed to add new Twitter user: {$twitter_id} - {$screen_name}.");
        common_log_db_error($fuser, 'INSERT', __FILE__);
    } else {
        common_log(LOG_INFO, "Twitter bridge - Added new Twitter user: {$screen_name} ({$twitter_id}).");
    }
    return $result;
}
开发者ID:Br3nda,项目名称:StatusNet,代码行数:27,代码来源:twitter.php

示例2: top

 static function top($transport)
 {
     $qi = new Queue_item();
     $qi->transport = $transport;
     $qi->orderBy('created');
     $qi->whereAdd('claimed is null');
     $qi->limit(1);
     $cnt = $qi->find(true);
     if ($cnt) {
         # XXX: potential race condition
         # can we force it to only update if claimed is still null
         # (or old)?
         common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
         $orig = clone $qi;
         $qi->claimed = common_sql_now();
         $result = $qi->update($orig);
         if ($result) {
             common_log(LOG_INFO, 'claim succeeded.');
             return $qi;
         } else {
             common_log(LOG_INFO, 'claim failed.');
         }
     }
     $qi = null;
     return null;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:26,代码来源:Queue_item.php

示例3: add

 static function add($peopletag, $profile)
 {
     if ($peopletag->private) {
         return false;
     }
     if (Event::handle('StartSubscribePeopletag', array($peopletag, $profile))) {
         $args = array('profile_tag_id' => $peopletag->id, 'profile_id' => $profile->id);
         $existing = Profile_tag_subscription::pkeyGet($args);
         if (!empty($existing)) {
             return $existing;
         }
         $sub = new Profile_tag_subscription();
         $sub->profile_tag_id = $peopletag->id;
         $sub->profile_id = $profile->id;
         $sub->created = common_sql_now();
         $result = $sub->insert();
         if (!$result) {
             common_log_db_error($sub, 'INSERT', __FILE__);
             // TRANS: Exception thrown when inserting a list subscription in the database fails.
             throw new Exception(_('Adding list subscription failed.'));
         }
         $ptag = Profile_list::getKV('id', $peopletag->id);
         $ptag->subscriberCount(true);
         Event::handle('EndSubscribePeopletag', array($peopletag, $profile));
         return $ptag;
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:27,代码来源:Profile_tag_subscription.php

示例4: top

 /**
  * @param mixed $transports name of a single queue or array of queues to pull from
  *                          If not specified, checks all queues in the system.
  */
 static function top($transports = null)
 {
     $qi = new Queue_item();
     if ($transports) {
         if (is_array($transports)) {
             // @fixme use safer escaping
             $list = implode("','", array_map(array($qi, 'escape'), $transports));
             $qi->whereAdd("transport in ('{$list}')");
         } else {
             $qi->transport = $transports;
         }
     }
     $qi->orderBy('created');
     $qi->whereAdd('claimed is null');
     $qi->limit(1);
     $cnt = $qi->find(true);
     if ($cnt) {
         // XXX: potential race condition
         // can we force it to only update if claimed is still null
         // (or old)?
         common_log(LOG_INFO, 'claiming queue item id = ' . $qi->id . ' for transport ' . $qi->transport);
         $orig = clone $qi;
         $qi->claimed = common_sql_now();
         $result = $qi->update($orig);
         if ($result) {
             common_log(LOG_INFO, 'claim succeeded.');
             return $qi;
         } else {
             common_log(LOG_INFO, 'claim failed.');
         }
     }
     $qi = null;
     return null;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:38,代码来源:Queue_item.php

示例5: saveNew

 static function saveNew($from, $to, $content, $source)
 {
     $sender = Profile::staticGet('id', $from);
     if (!$sender->hasRight(Right::NEWMESSAGE)) {
         // TRANS: Client exception thrown when a user tries to send a direct message while being banned from sending them.
         throw new ClientException(_('You are banned from sending direct messages.'));
     }
     $msg = new Message();
     $msg->from_profile = $from;
     $msg->to_profile = $to;
     $msg->content = common_shorten_links($content);
     $msg->rendered = common_render_text($content);
     $msg->created = common_sql_now();
     $msg->source = $source;
     $result = $msg->insert();
     if (!$result) {
         common_log_db_error($msg, 'INSERT', __FILE__);
         // TRANS: Message given when a message could not be stored on the server.
         return _('Could not insert message.');
     }
     $orig = clone $msg;
     $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
     $result = $msg->update($orig);
     if (!$result) {
         common_log_db_error($msg, 'UPDATE', __FILE__);
         // TRANS: Message given when a message could not be updated on the server.
         return _('Could not update message with new URI.');
     }
     return $msg;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:30,代码来源:Message.php

示例6: saveNew

 public static function saveNew(Profile $subscriber, Profile $subscribed)
 {
     $rq = new Subscription_queue();
     $rq->subscriber = $subscriber->id;
     $rq->subscribed = $subscribed->id;
     $rq->created = common_sql_now();
     $rq->insert();
     return $rq;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:9,代码来源:Subscription_queue.php

示例7: saveNew

 public static function saveNew(Profile $profile, User_group $group)
 {
     $rq = new Group_join_queue();
     $rq->profile_id = $profile->id;
     $rq->group_id = $group->id;
     $rq->created = common_sql_now();
     $rq->insert();
     return $rq;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:9,代码来源:Group_join_queue.php

示例8: fromUrl

 public static function fromUrl($url, $depth = 0)
 {
     common_debug('MentionURL: trying to find a profile for ' . $url);
     $url = preg_replace('#https?://#', 'https://', $url);
     try {
         $profile = Profile::fromUri($url);
     } catch (UnknownUriException $ex) {
     }
     if (!$profile instanceof Profile) {
         $profile = self::findProfileByProfileURL($url);
     }
     $url = str_replace('https://', 'http://', $url);
     if (!$profile instanceof Profile) {
         try {
             $profile = Profile::fromUri($url);
         } catch (UnknownUriException $ex) {
         }
     }
     if (!$profile instanceof Profile) {
         $profile = self::findProfileByProfileURL($url);
     }
     if (!$profile instanceof Profile) {
         $hcard = mention_url_representative_hcard($url);
         if (!$hcard) {
             return null;
         }
         $mention_profile = new Mention_url_profile();
         $mention_profile->query('BEGIN');
         $profile = new Profile();
         $profile->profileurl = $hcard['url'][0];
         $profile->fullname = $hcard['name'][0];
         preg_match('/\\/([^\\/]+)\\/*$/', $profile->profileurl, $matches);
         if (!$hcard['nickname']) {
             $hcard['nickname'] = array($matches[1]);
         }
         $profile->nickname = $hcard['nickname'][0];
         $profile->created = common_sql_now();
         $mention_profile->profile_id = $profile->insert();
         if (!$mention_profile->profile_id) {
             $mention_profile->query('ROLLBACK');
             return null;
         }
         $mention_profile->profileurl = $profile->profileurl;
         if (!$mention_profile->insert()) {
             $mention_profile->query('ROLLBACK');
             if ($depth > 0) {
                 return null;
             } else {
                 return self::fromUrl($url, $depth + 1);
             }
         } else {
             $mention_profile->query('COMMIT');
         }
     }
     return $profile;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:56,代码来源:Mention_url_profile.php

示例9: start

 /**
  * Start a search subscription!
  *
  * @param profile $profile subscriber
  * @param string $search subscribee
  * @return SearchSub
  */
 static function start(Profile $profile, $search)
 {
     $ts = new SearchSub();
     $ts->search = $search;
     $ts->profile_id = $profile->id;
     $ts->created = common_sql_now();
     $ts->insert();
     self::blow('searchsub:by_profile:%d', $profile->id);
     return $ts;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:17,代码来源:SearchSub.php

示例10: create

 /**
  * Factory method for creating a new conversation.
  *
  * Use this for locally initiated conversations. Remote notices should
  * preferrably supply their own conversation URIs in the OStatus feed.
  *
  * @return Conversation the new conversation DO
  */
 static function create($uri = null, $created = null)
 {
     // Be aware that the Notice does not have an id yet since it's not inserted!
     $conv = new Conversation();
     $conv->created = $created ?: common_sql_now();
     $conv->uri = $uri ?: sprintf('%s%s=%s:%s=%s', TagURI::mint(), 'objectType', 'thread', 'nonce', common_random_hexstr(8));
     // This insert throws exceptions on failure
     $conv->insert();
     return $conv;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:18,代码来源:Conversation.php

示例11: start

 /**
  * Start a tag subscription!
  *
  * @param profile $profile subscriber
  * @param string $tag subscribee
  * @return TagSub
  */
 static function start(Profile $profile, $tag)
 {
     $ts = new TagSub();
     $ts->tag = $tag;
     $ts->profile_id = $profile->id;
     $ts->created = common_sql_now();
     $ts->insert();
     self::blow('tagsub:by_profile:%d', $profile->id);
     return $ts;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:17,代码来源:TagSub.php

示例12: generateNew

 static function generateNew()
 {
     $cons = new Consumer();
     $rand = common_good_rand(16);
     $cons->seed = $rand;
     $cons->consumer_key = md5(time() + $rand);
     $cons->consumer_secret = md5(md5(time() + time() + $rand));
     $cons->created = common_sql_now();
     return $cons;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:10,代码来源:Consumer.php

示例13: saveNew

 public static function saveNew(Profile $subscriber, Profile $subscribed)
 {
     if (self::exists($subscriber, $subscribed)) {
         throw new AlreadyFulfilledException(_('This subscription request is already in progress.'));
     }
     $rq = new Subscription_queue();
     $rq->subscriber = $subscriber->id;
     $rq->subscribed = $subscribed->id;
     $rq->created = common_sql_now();
     $rq->insert();
     return $rq;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:12,代码来源:Subscription_queue.php

示例14: register

 /**
  * Register a user with a username on a given provider
  * @param User User object
  * @param string username on the given provider
  * @param provider_name string name of the provider
  * @return mixed User_username instance if the registration succeeded, false if it did not
  */
 static function register($user, $username, $provider_name)
 {
     $user_username = new User_username();
     $user_username->user_id = $user->id;
     $user_username->provider_name = $provider_name;
     $user_username->username = $username;
     $user_username->created = common_sql_now();
     if ($user_username->insert()) {
         return $user_username;
     } else {
         return false;
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:20,代码来源:User_username.php

示例15: send

 function send($gm, $profile)
 {
     $gmp = new Group_message_profile();
     $gmp->group_message_id = $gm->id;
     $gmp->to_profile = $profile->id;
     $gmp->created = common_sql_now();
     $gmp->insert();
     // If it's not for the author, send email notification
     if ($gm->from_profile != $profile->id) {
         $gmp->notify();
     }
     return $gmp;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:13,代码来源:Group_message_profile.php


注:本文中的common_sql_now函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。