| @@ 95-106 (lines=12) @@ | ||
| 92 | * @param string $name |
|
| 93 | * @return bool |
|
| 94 | */ |
|
| 95 | public function exists($name) |
|
| 96 | { |
|
| 97 | if (! $name) { |
|
| 98 | return false; |
|
| 99 | } |
|
| 100 | ||
| 101 | $name = $this->wrap($name); |
|
| 102 | ||
| 103 | return $this->connection->selectOne( |
|
| 104 | "select * from all_sequences where sequence_name=upper('{$name}') and sequence_owner=upper(user)" |
|
| 105 | ); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * get sequence next value. |
|
| @@ 114-123 (lines=10) @@ | ||
| 111 | * @param string $name |
|
| 112 | * @return int |
|
| 113 | */ |
|
| 114 | public function nextValue($name) |
|
| 115 | { |
|
| 116 | if (! $name) { |
|
| 117 | return 0; |
|
| 118 | } |
|
| 119 | ||
| 120 | $name = $this->wrap($name); |
|
| 121 | ||
| 122 | return $this->connection->selectOne("SELECT $name.NEXTVAL as id FROM DUAL")->id; |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * same function as lastInsertId. added for clarity with oracle sql statement. |
|
| @@ 142-152 (lines=11) @@ | ||
| 139 | * @param string $name |
|
| 140 | * @return int |
|
| 141 | */ |
|
| 142 | public function lastInsertId($name) |
|
| 143 | { |
|
| 144 | // check if a valid name and sequence exists |
|
| 145 | if (! $name || ! $this->exists($name)) { |
|
| 146 | return 0; |
|
| 147 | } |
|
| 148 | ||
| 149 | $name = $this->wrap($name); |
|
| 150 | ||
| 151 | return $this->connection->selectOne("select {$name}.currval as id from dual")->id; |
|
| 152 | } |
|
| 153 | } |
|
| 154 | ||