| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
class DBPostgres extends DBAdapter { |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
* This method is used to ignore case. |
|---|
| 37 |
* |
|---|
| 38 |
* @param string $in The string to transform to upper case. |
|---|
| 39 |
* @return string The upper case string. |
|---|
| 40 |
*/ |
|---|
| 41 |
public function toUpperCase($in) |
|---|
| 42 |
{ |
|---|
| 43 |
return "UPPER(" . $in . ")"; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
* This method is used to ignore case. |
|---|
| 48 |
* |
|---|
| 49 |
* @param in The string whose case to ignore. |
|---|
| 50 |
* @return The string in a case that can be ignored. |
|---|
| 51 |
*/ |
|---|
| 52 |
public function ignoreCase($in) |
|---|
| 53 |
{ |
|---|
| 54 |
return "UPPER(" . $in . ")"; |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
* Returns SQL which concatenates the second string to the first. |
|---|
| 59 |
* |
|---|
| 60 |
* @param string String to concatenate. |
|---|
| 61 |
* @param string String to append. |
|---|
| 62 |
* @return string |
|---|
| 63 |
*/ |
|---|
| 64 |
public function concatString($s1, $s2) |
|---|
| 65 |
{ |
|---|
| 66 |
return "($s1 || $s2)"; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
* Returns SQL which extracts a substring. |
|---|
| 71 |
* |
|---|
| 72 |
* @param string String to extract from. |
|---|
| 73 |
* @param int Offset to start from. |
|---|
| 74 |
* @param int Number of characters to extract. |
|---|
| 75 |
* @return string |
|---|
| 76 |
*/ |
|---|
| 77 |
public function subString($s, $pos, $len) |
|---|
| 78 |
{ |
|---|
| 79 |
return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")"; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
* Returns SQL which calculates the length (in chars) of a string. |
|---|
| 84 |
* |
|---|
| 85 |
* @param string String to calculate length of. |
|---|
| 86 |
* @return string |
|---|
| 87 |
*/ |
|---|
| 88 |
public function strLength($s) |
|---|
| 89 |
{ |
|---|
| 90 |
return "char_length($s)"; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
* @see DBAdapter::getIdMethod() |
|---|
| 95 |
*/ |
|---|
| 96 |
protected function getIdMethod() |
|---|
| 97 |
{ |
|---|
| 98 |
return DBAdapter::ID_METHOD_SEQUENCE; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
* Gets ID for specified sequence name. |
|---|
| 103 |
*/ |
|---|
| 104 |
public function getId(PDO $con, $name = null) |
|---|
| 105 |
{ |
|---|
| 106 |
if ($name === null) { |
|---|
| 107 |
throw new PropelException("Unable to fetch next sequence ID without sequence name."); |
|---|
| 108 |
} |
|---|
| 109 |
$stmt = $con->query("SELECT nextval(".$con->quote($name).")"); |
|---|
| 110 |
$row = $stmt->fetch(PDO::FETCH_NUM); |
|---|
| 111 |
return $row[0]; |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
* Returns timestamp formatter string for use in date() function. |
|---|
| 116 |
* @return string |
|---|
| 117 |
*/ |
|---|
| 118 |
public function getTimestampFormatter() |
|---|
| 119 |
{ |
|---|
| 120 |
return "Y-m-d H:i:s O"; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
* Returns timestamp formatter string for use in date() function. |
|---|
| 125 |
* @return string |
|---|
| 126 |
*/ |
|---|
| 127 |
public function getTimeFormatter() |
|---|
| 128 |
{ |
|---|
| 129 |
return "H:i:s O"; |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
* @see DBAdapter::applyLimit() |
|---|
| 134 |
*/ |
|---|
| 135 |
public function applyLimit(&$sql, $offset, $limit) |
|---|
| 136 |
{ |
|---|
| 137 |
if ( $limit > 0 ) { |
|---|
| 138 |
$sql .= " LIMIT ".$limit; |
|---|
| 139 |
} |
|---|
| 140 |
if ( $offset > 0 ) { |
|---|
| 141 |
$sql .= " OFFSET ".$offset; |
|---|
| 142 |
} |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
* @see DBAdapter::random() |
|---|
| 147 |
*/ |
|---|
| 148 |
public function random($seed=NULL) |
|---|
| 149 |
{ |
|---|
| 150 |
return 'random()'; |
|---|
| 151 |
} |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|