# Source for file Oracle.php

Documentation is available at Oracle.php

1. <?php
2. /*
3. * $Id: Oracle.php 1119 2007-02-17 18:21:26Z zYne $
4. *
5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16. *
17. * This software consists of voluntary contributions made by many individuals
18. * and is licensed under the LGPL. For more information, see
19. * <http://www.phpdoctrine.com>.
20. */
21. Doctrine::autoload('Doctrine_Transaction');
22. /**
23. *
24. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
25. * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
27. * @package Doctrine
28. * @category Object Relational Mapping
29. * @link www.phpdoctrine.com
30. * @since 1.0
31. * @version $Revision: 1119 $
32. */
33. class Doctrine_Transaction_Oracle extends Doctrine_Transaction
34. {
35. /**
36. * createSavepoint
37. * creates a new savepoint
38. *
39. * @param string $savepoint name of a savepoint to set
40. * @return void
41. */
42. protected function createSavePoint($savepoint)
43. {
44. $query = 'SAVEPOINT ' . $savepoint;
46. return $this->conn->execute($query);
47. }
48. /**
49. * releaseSavePoint
50. * releases given savepoint
51. *
52. * @param string $savepoint name of a savepoint to release
53. * @return void
54. */
55. protected function releaseSavePoint($savepoint)
56. {
57. // oracle doesn't support manual releasing of savepoints
58. return true;
59. }
60. /**
61. * rollbackSavePoint
62. * releases given savepoint
63. *
64. * @param string $savepoint name of a savepoint to rollback to
65. * @return void
66. */
67. protected function rollbackSavePoint($savepoint)
68. {
69. $query = 'ROLLBACK TO SAVEPOINT ' . $savepoint;
71. return $this->conn->execute($query);
72. }
73. /**
74. * Set the transacton isolation level.
75. *
76. * @param string standard isolation level
77. * READ UNCOMMITTED (allows dirty reads)
78. * READ COMMITTED (prevents dirty reads)
79. * REPEATABLE READ (prevents nonrepeatable reads)
80. * SERIALIZABLE (prevents phantom reads)
81. * @throws PDOException if something fails at the PDO level
82. * @throws Doctrine_Transaction_Exception if using unknown isolation level
83. * @return void
84. */
85. public function setIsolation($isolation)
86. {
87. switch ($isolation) {
88. case 'READ UNCOMMITTED':
89. $isolation = 'READ COMMITTED';
90. break;
91. case 'READ COMMITTED':
92. case 'REPEATABLE READ':
93. case 'SERIALIZABLE':
94. $isolation = 'SERIALIZABLE';
95. break;
96. default:
97. throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.');
98. }
100. $query = 'ALTER SESSION ISOLATION LEVEL ' . $isolation;
101. return $this->conn->execute($query);
102. }
103. }