Last active
December 15, 2015 05:39
-
-
Save phalcon/5210461 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| use Phalcon\Mvc\Model\Transaction\Manager as TxManager; | |
| class TestTask extends \Phalcon\CLI\Task | |
| { | |
| public function doAction() | |
| { | |
| $config = $GLOBALS['config']; | |
| $this->di->set("transactionManager", new TxManager()); | |
| for ($i = 0; $i < 9999999; $i++) { | |
| $this->ins(); | |
| } | |
| } | |
| private function ins() | |
| { | |
| $manager = $this->di["transactionManager"]; | |
| $transaction = $manager->get(); | |
| $project = new \Models\Project(); | |
| $project->setTransaction($transaction); | |
| $project->name = 'Test'; | |
| $project->description = 'Some text...'; | |
| if (true != $project->save()) { | |
| $transaction->rollBack("Unable to save Project. errors:" . print_r($project->getMessages(), true)); | |
| } | |
| $target = new \Models\Target(); | |
| $target->setTransaction($transaction); | |
| $target->name = 'Target name'; | |
| $target->project_id = $project->id; | |
| if (true != $target->save()) { | |
| $transaction->rollBack("Unable to save Target. errors:" . print_r($target->getMessages(), true)); | |
| } | |
| $transaction->commit(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment