本文整理汇总了PHP中Apartment::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Apartment::update方法的具体用法?PHP Apartment::update怎么用?PHP Apartment::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apartment
的用法示例。
在下文中一共展示了Apartment::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preparePosting
public static function preparePosting(Apartment $model)
{
if ($model) {
$message = '';
$defaultLang = Lang::getDefaultLang();
$tmp = 'title_' . $defaultLang;
if (isset($model->{$tmp})) {
$message .= $model->{$tmp};
}
// vkontakte
if (SocialpostingModel::getSocialParamValue('useVkontakte')) {
$vkApId = SocialpostingModel::getSocialParamValue('vkontakteApplicationId');
$vkToken = SocialpostingModel::getSocialParamValue('vkontakteToken');
$vkUsId = SocialpostingModel::getSocialParamValue('vkontakteUserId');
//if ($vkApId && $vkToken && !is_numeric($model->autoVKPostId)) {
if ($vkApId && $vkToken && utf8_strlen($model->autoVKPostId) < 1) {
if ($message) {
$imageUrl = null;
$res = Images::getMainThumb(300, 200, $model->images);
if ($res['link']) {
$imageUrl = $res['link'];
}
$post = self::addPostToVK($message, $vkApId, $vkToken, $vkUsId, $model->getUrl(), $imageUrl);
//logs(var_export($post, false));
//logs(var_export($post, true));
$postId = '0';
if ($post && isset($post->response)) {
$postId = isset($post->response->post_id) && $post->response->post_id ? $post->response->post_id : 0;
}
$model->autoVKPostId = $postId;
$model->update(array('autoVKPostId'));
/*$sql = 'UPDATE {{apartment}} SET autoVKPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
Yii::app()->db->createCommand($sql)->execute();*/
}
}
}
// twitter
if (SocialpostingModel::getSocialParamValue('useTwitter')) {
$twApiKey = SocialpostingModel::getSocialParamValue('twitterApiKey');
$twApiSecret = SocialpostingModel::getSocialParamValue('twitterApiSecret');
$twTokenKey = SocialpostingModel::getSocialParamValue('twitterTokenKey');
$twTokenSecret = SocialpostingModel::getSocialParamValue('twitterTokenSecret');
//if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && !is_numeric($model->autoTwitterPostId)) {
if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && utf8_strlen($model->autoTwitterPostId) < 1) {
if ($message) {
$post = self::addPostToTw($message, $twApiKey, $twApiSecret, $twTokenKey, $twTokenSecret, $model->getUrl());
//logs(var_export($post, false));
//logs(var_export($post, true));
$postId = '0';
if ($post && isset($post->id_str)) {
$postId = $post->id_str ? $post->id_str : 0;
}
$model->autoTwitterPostId = strip_tags(addslashes($postId));
$model->update(array('autoTwitterPostId'));
/*$sql = 'UPDATE {{apartment}} SET autoTwitterPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
Yii::app()->db->createCommand($sql)->execute();*/
}
}
}
}
return true;
}