/** * Add an image * * @param integer $categoryId * @param array $imageInfo * string name * string description * string url * @param array $image * @return boolean|string */ public function addImage($categoryId, array $imageInfo, array $image = []) { try { $this->adapter->getDriver()->getConnection()->beginTransaction(); $insert = $this->insert()->into('slideshow_image')->values(array_merge($imageInfo, ['category_id' => $categoryId, 'created' => time()])); $statement = $this->prepareStatementForSqlObject($insert); $statement->execute(); $insertId = $this->adapter->getDriver()->getLastGeneratedValue(); // upload the image $this->uploadImage($insertId, $image); $this->adapter->getDriver()->getConnection()->commit(); } catch (Exception $e) { $this->adapter->getDriver()->getConnection()->rollback(); ApplicationErrorLogger::log($e); return $e->getMessage(); } // fire the add image event SlideshowEvent::fireAddImageEvent($insertId); return true; }