Commit 81dc80a8 authored by Shakarim Sapa's avatar Shakarim Sapa

- Выгружаем запрос

parent 96c6004f
<?php
namespace console\controllers;
use common\modules\blog\models\PostLang;
use yii\console\Controller;
use yii\web\ServerErrorHttpException;
class ReplaceController extends Controller
{
public function actionBlog()
{
$data = PostLang::find()->all();
$transaction = \Yii::$app()->db->beginTransaction();
try
{
foreach($data as $item)
{
$item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text);
if (!$item->save())
{
throw new ServerErrorHttpException(current(current($item->getErrors())));
}
}
$transaction->commit();
}
catch(\Exception $e)
{
echo "[".$e->getCode()."]".$e->getMessage();
echo "\n";
$transaction->rollback();
}
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment