LoginSignup
0
0

More than 3 years have passed since last update.

Cake 2.xでトランザクションが効かなかった対応

Posted at

バッチ

$model = ClassRegistry::init('Model名');
foreach ($tmp as $key => $t) {
    $model->begin();
    if (!$this->TmpModel->testMethod($t)) continue;

    //省略saveを使った更新処理
    $model->commit();
}

この場合、continueで次の処理に行った場合、次の処理でコミットもできなくなる。
beginはcontinueの後に行う。

$model = ClassRegistry::init('Model名');
foreach ($tmp as $key => $t) {
    if (!$this->TmpModel->testMethod($t)) continue;

    $model->begin();
    //省略saveを使った更新処理
    $model->commit();
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0