本文整理匯總了PHP中common\models\Comment::setIp方法的典型用法代碼示例。如果您正苦於以下問題:PHP Comment::setIp方法的具體用法?PHP Comment::setIp怎麽用?PHP Comment::setIp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\Comment
的用法示例。
在下文中一共展示了Comment::setIp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: up
public function up()
{
$comments = new \yii\db\Query();
$comments = $comments->from(\Yii::$app->params['oldDb'] . '.joom_jcomments');
$commentsCount = $comments->count();
echo " > migrating comments... Almost have {$commentsCount} comments...\r\n";
echo " > prepare comments...\r\n";
$i = 0;
$prepared = [];
foreach ($comments->each() as $comment) {
$i++;
echo " > comment {$i} from {$commentsCount}... \r\n";
$commentModel = new Comment(['newsID' => $comment['object_id'], 'author' => $comment['name'], 'email' => $comment['email'], 'text' => $comment['comment'], 'date' => strtotime($comment['date']), 'isGood' => $comment['isgood'], 'isBad' => $comment['ispoor'], 'published' => $comment['published'], 'deleted' => $comment['deleted'], 'id' => $comment['id']]);
$commentModel->setIp($comment['ip']);
if (!empty($commentModel->ip) && mb_strlen($commentModel->author, 'utf8') < 64 && $commentModel->date > 0 && $commentModel->date < time() + 86400) {
$prepared[] = $commentModel->attributes;
}
if (count($prepared) >= 100 || $commentsCount - $i == 0) {
$this->batchInsert(Comment::tableName(), array_keys($prepared[0]), $prepared);
$prepared = [];
}
}
}