Skip to content

Instantly share code, notes, and snippets.

@hiromi2424
Created March 6, 2011 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiromi2424/857327 to your computer and use it in GitHub Desktop.
Save hiromi2424/857327 to your computer and use it in GitHub Desktop.
<?php
class Service {
function addArticle($data) {
$this->Transaction->begin();
if (!$this->Article->save($this->Article->create($data))) {
$this->Transaction->begin();
return false;
}
$this->Transaction->commit();
return true;
}
}
<?php
class Service {
function addArticle($data) {
if (!$this->Article->save($this->Article->create($data))) {
return false;
}
return true;
}
function addArticleByMember($data) {
$this->Transaction->begin();
if (!$this->addArticle($data)) {
$this->Transaction->begin();
return false;
}
$this->Transaction->commit();
return true;
}
function addArticleByAdmin($data) {
$this->Transaction->begin();
$data['is_admin'] = true;
if (!$this->addArticle($data)) {
$this->Transaction->begin();
return false;
}
$this->Transaction->commit();
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment