Created
March 6, 2011 14:22
-
-
Save hiromi2424/857327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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