Commit f7092b14 authored by Shakarim Sapa's avatar Shakarim Sapa

- Fix

parent f732f139
<?php
namespace console\controllers;
use common\modules\content\models\CoBlocksLang;
use common\modules\content\models\CoContentLang;
use Yii;
use common\modules\blog\models\PostLang;
......@@ -53,6 +54,38 @@ class ReplaceController extends Controller
$item->text = str_replace('http://task-on.com/', '/', $item->text);
if (!$item->update())
{
// throw new ServerErrorHttpException(current(current($item->getErrors())));
}
echo "[".$item->getPrimaryKey()."] ".($i+1)." of ".count($data)." successfully updated\n";
}
}
$transaction->commit();
}
catch(\Exception $e)
{
echo "[".$e->getCode()."]".$e->getMessage();
echo "\n";
$transaction->rollback();
}
}
/**
* @throws \yii\web\ServerErrorHttpException
*/
public function actionBlocks()
{
$data = CoBlocksLang::find()->all();
$transaction = Yii::$app->db->beginTransaction();
try
{
foreach($data as $i=>$item)
{
if ($item->text!='')
{
// $item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text);
$item->text = str_replace('http://task-on.com/', '/', $item->text);
if (!$item->update())
{
// throw new ServerErrorHttpException(current(current($item->getErrors())));
}
echo "[".$item->getPrimaryKey()."] ".($i+1)." of ".count($data)." successfully updated\n";
......
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