/** * Insert or update application 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) { $data = $image['data']; if (is_numeric($image['id']) && $image['id'] > 0) { // Update existing image $item = Model_Image::find_one_by_id($image['id']); $item->set($data); } else { $item = Model_Image::forge($data); } $item->save(); } }