# Source for file Oracle.php

Documentation is available at Oracle.php

1. <?php
2. /*
3. * $Id: Oracle.php 1917 2007-07-01 11:27:45Z 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_Expression_Driver');
22. /**
23. * Doctrine_Expression_Sqlite
24. *
25. * @package Doctrine
26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
27. * @category Object Relational Mapping
28. * @link www.phpdoctrine.com
29. * @since 1.0
30. * @version $Revision: 1917 $
31. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
32. */
33. class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver
34. {
35. /**
36. * Returns a series of strings concatinated
37. *
38. * concat() accepts an arbitrary number of parameters. Each parameter
39. * must contain an expression
40. *
41. * @param string $arg1, $arg2 ... $argN strings that will be concatinated.
42. * @return string
43. */
44. public function concat()
45. {
46. $args = func_get_args();
48. return join(' || ' , $args);
49. }
50. /**
51. * return string to call a function to get a substring inside an SQL statement
52. *
53. * Note: Not SQL92, but common functionality.
54. *
55. * @param string $value an sql string literal or column name/alias
56. * @param integer $position where to start the substring portion
57. * @param integer $length the substring portion length
58. * @return string SQL substring function with given parameters
59. */
60. public function substring($value, $position, $length = null)
61. {
62. if ($length !== null)
63. return "SUBSTR($value, $position, $length)";
65. return "SUBSTR($value, $position)";
66. }
67. /**
68. * Return string to call a variable with the current timestamp inside an SQL statement
69. * There are three special variables for current date and time:
70. * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
71. * - CURRENT_DATE (date, DATE type)
72. * - CURRENT_TIME (time, TIME type)
73. *
74. * @return string to call a variable with the current timestamp
75. */
76. public function now($type = 'timestamp')
77. {
78. switch ($type) {
79. case 'date':
80. case 'time':
81. case 'timestamp':
82. default:
83. return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')';
84. }
85. }
86. /**
87. * random
88. *
89. * @return string an oracle SQL string that generates a float between 0 and 1
90. */
91. public function random()
92. {
93. return 'dbms_random.value';
94. }
95. /**
96. * Returns global unique identifier
97. *
98. * @return string to get global unique identifier
99. */
100. public function guid()
101. {
102. return 'SYS_GUID()';
103. }
104. }