本文整理汇总了PHP中Foreign_link::safeDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP Foreign_link::safeDelete方法的具体用法?PHP Foreign_link::safeDelete怎么用?PHP Foreign_link::safeDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foreign_link
的用法示例。
在下文中一共展示了Foreign_link::safeDelete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveForeignLink
/**
* Saves a Foreign_link between Twitter user and local user,
* which includes the access token and secret.
*
* @param int $user_id StatusNet user ID
* @param int $twuid Twitter user ID
* @param OAuthToken $token the access token to save
*
* @return nothing
*/
function saveForeignLink($user_id, $twuid, $access_token)
{
$flink = new Foreign_link();
$flink->user_id = $user_id;
$flink->service = TWITTER_SERVICE;
// delete stale flink, if any
$result = $flink->find(true);
if (!empty($result)) {
$flink->safeDelete();
}
$flink->user_id = $user_id;
$flink->foreign_id = $twuid;
$flink->service = TWITTER_SERVICE;
$creds = TwitterOAuthClient::packToken($access_token);
$flink->credentials = $creds;
$flink->created = common_sql_now();
// Defaults: noticesync on, everything else off
$flink->set_flags(true, false, false, false);
$flink_id = $flink->insert();
if (empty($flink_id)) {
common_log_db_error($flink, 'INSERT', __FILE__);
// TRANS: Server error displayed when linking to a Twitter account fails.
$this->serverError(_m('Could not link your Twitter account.'));
}
return $flink_id;
}