php - Database transaction doesn't roll back in JModelAdmin - Joomla 3.x -



php - Database transaction doesn't roll back in JModelAdmin - Joomla 3.x -

i developping calendar component joomla 3.x. utilize mysql 5.5.32

in backend, have form save event info in database , upload image.

to deal image extend jmodeladmin , override save function.

public function save($data) { [...] $db = $this->getdbo(); seek { $db->transactionstart(); // move uploaded image in right folder if($image = fileutility::preprocessjformfile('image', '/images/aftevents/')) { $fileextension = jfile::getext($image); // register image extension saved in database $data['image_ext'] = $fileextension; } if (parent::save($data)) { // rename image event id if($image) { $id = $data['id'] ? $data['id'] : $this->getstate($this->getname().'.id', 0); if(!$id) { throw new exception('com_aftevents_exception_no_id', 1502); } $finalimage = jpath_root.'/images/aftevents/'. $id .'.'. $fileextension; jfile::move($image, $finalimage); // create thumbnails $params = jcomponenthelper::getparams('com_aftevents'); $params->toarray(); $iewidth = $params['image_event_width']; $ieheight = $params['image_event_height']; $icwidth = $params['calendar_image_event_width']; $icheight = $params['calendar_image_event_height']; $jimage = new jimage($finalimage); $thumbs = $jimage->createthumbs(array($iewidth.'x'.$ieheight, $icwidth.'x'.$icheight), 5); } $db->transactioncommit(); homecoming true; } } grab (exception $e) { // grab database errors. $db->transactionrollback(); $this->seterror($e->getmessage()); homecoming false; } homecoming false; }

now transaction doesn't work. if exception caught, insertion in database isn't rolled back.

i believe because transaction instructions , database insertion not called same jdatabasedriver object or somewhere in parent classes transaction used when the record saved in database , messes one.

does know how create transaction work?

php mysql joomla transactions

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -