Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. public function actionTest()
  2.     {
  3.         $contents = Content::findAll(['type'=>Content::TYPE_SPIN]);
  4.         foreach ($contents as $content) {
  5.             $re = '/([^\/]+$)/m';
  6.             preg_match($re, $content->aws_s3_object, $matches);
  7.             if(!empty($matches[0])){
  8.                 $content_video = Content::find()->where(['like','aws_s3_object','%'.$matches[0].'%',false])->andWhere(['type'=>Content::TYPE_VIDEO])->one();
  9.                 if($content_video){
  10.                     $contentBinding = new ContentBindings();
  11.                     $contentBinding->parent_id = $content->id;
  12.                     $contentBinding->child_id = $content_video->id;
  13.                     $contentBinding->save();
  14.                 }
  15.  
  16.             }
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement