Example #1
0
 /**
  * Insert or update page images
  * Certain array structure need to be passed
  * 
  * array(
  * 	0 => array(
  * 		'id' 	=> If numeric and larger than 0, image will be updated. Otherwise image is considered new
  * 		'data'	=> Array of image data to insert
  * 	),
  * 	1 => array(
  * 		'id' 	=> If numeric and larger than 0, image will be updated. Otherwise image is considered new
  * 		'data'	=> Array of image data to insert
  * 	),
  * 	etc.
  * )
  * 
  * @param $images
  */
 public static function bind_images($images = array())
 {
     if (empty($images) || !is_array($images)) {
         return false;
     }
     foreach ($images as $key => $image) {
         $item = Model_Attribute_Image::forge($image['data']);
         if (is_numeric($image['id']) && $image['id'] > 0) {
             // Update existing image
             $item->set(array('id' => $image['id']));
             $item->is_new(false);
         }
         $item->save();
     }
 }