123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- class DBPostgres extends DBAdapter
- {
-
- public function toUpperCase($in)
- {
- return "UPPER(" . $in . ")";
- }
-
- public function ignoreCase($in)
- {
- return "UPPER(" . $in . ")";
- }
-
- public function concatString($s1, $s2)
- {
- return "($s1 || $s2)";
- }
-
- public function subString($s, $pos, $len)
- {
- return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")";
- }
-
- public function strLength($s)
- {
- return "char_length($s)";
- }
-
- protected function getIdMethod()
- {
- return DBAdapter::ID_METHOD_SEQUENCE;
- }
-
- public function getId(PDO $con, $name = null)
- {
- if ($name === null) {
- throw new PropelException("Unable to fetch next sequence ID without sequence name.");
- }
- $stmt = $con->query("SELECT nextval(".$con->quote($name).")");
- $row = $stmt->fetch(PDO::FETCH_NUM);
- return $row[0];
- }
-
- public function getTimestampFormatter()
- {
- return "Y-m-d H:i:s O";
- }
-
- public function getTimeFormatter()
- {
- return "H:i:s O";
- }
-
- public function applyLimit(&$sql, $offset, $limit)
- {
- if ( $limit > 0 ) {
- $sql .= " LIMIT ".$limit;
- }
- if ( $offset > 0 ) {
- $sql .= " OFFSET ".$offset;
- }
- }
-
-
- public function random($seed=NULL)
- {
- return 'random()';
- }
- }
|