Exemplo n.º 1
0
 /**
  * Insert or update application videos
  * Certain array structure need to be passed
  * 
  * array(
  * 	0 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	1 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	etc.
  * )
  * 
  * @param $files
  */
 public static function bind_videos($videos = array())
 {
     if (empty($videos) || !is_array($videos)) {
         return false;
     }
     foreach ($videos as $key => $video) {
         $data = $video['data'];
         if (is_numeric($video['id']) && $video['id'] > 0) {
             // Update existing video
             $item = Model_Video::find_one_by_id($video['id']);
             $item->set($data);
         } else {
             $item = Model_Video::forge($data);
         }
         $item->save();
     }
 }