Commit 0b6765da authored by Shakarim Sapa's avatar Shakarim Sapa

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

parent 81dc80a8
...@@ -14,13 +14,14 @@ class ReplaceController extends Controller ...@@ -14,13 +14,14 @@ class ReplaceController extends Controller
$transaction = \Yii::$app()->db->beginTransaction(); $transaction = \Yii::$app()->db->beginTransaction();
try try
{ {
foreach($data as $item) foreach($data as $i=>$item)
{ {
$item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text); $item->text = str_replace('http://task-on.com/', 'https://task-on.com/', $item->text);
if (!$item->save()) if (!$item->save())
{ {
throw new ServerErrorHttpException(current(current($item->getErrors()))); throw new ServerErrorHttpException(current(current($item->getErrors())));
} }
echo $i." of ".count($data)."successfully updated\n";
} }
$transaction->commit(); $transaction->commit();
} }
......
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