コード例 #1
0
 protected function _rollbackTransaction()
 {
   rollbackUserTransaction();
 }
コード例 #2
0
  function testTransactions()
  {
    $db =& DbFactory :: instance();

    startUserTransaction();

    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon', 'dog_name' => null));
    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon2', 'dog_name' => null));
    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon3', 'dog_name' => null));

    rollbackUserTransaction();

    $db->sqlSelect("founding_fathers", '*', 'last="Nixon"');
    $this->assertEqual(sizeof($db->getArray()), 0);

    startUserTransaction();

    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon', 'dog_name' => null));
    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon2', 'dog_name' => null));
    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon3', 'dog_name' => null));

    commitUserTransaction();

    $db->sqlSelect("founding_fathers", '*', 'last="Nixon" OR last="Nixon2" OR last="Nixon3"');
    $this->assertEqual(sizeof($db->getArray()), 3);

    startUserTransaction();

    $db->sqlInsert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixxxxx', 'dog_name' => null));

    $db->sqlSelect("founding_fathers", '*', 'last="Nixxxxx"');
    $arr = $db->getArray();
    $this->assertEqual(sizeof($arr), 1);
    $this->assertEqual($arr[0]['last'], 'Nixxxxx');

    rollbackUserTransaction();

    $db->sqlSelect("founding_fathers", '*', 'last="Nixxxxx"');
    $arr = $db->getArray();
    $this->assertEqual(sizeof($arr), 0);
  }