13 require_once dirname(__FILE__).
'/DALConverter.inc';
34 protected $name =
'Postgres';
61 $sql .=
"\n".$this->convertCreateColumns($table).
',';
62 $sql .=
"\n".$this->convertConstraints($table[
'CONSTRAINTS']);
66 if ($indexes !==
'') {
67 $sql .=
"\n".$indexes;
70 if (isset($table[
'SEQUENCES']) === TRUE) {
71 $sql .=
"\n".$this->convertCreateSequences($table[
'SEQUENCES']);
91 foreach ($table[
'INDEXES'] as $index) {
95 $sql .= implode(
";\n", $indexes).
';';
115 $sql =
'CREATE INDEX '.$idx[
'name'].
' ON '.$tableName.
' (';
135 $sql =
'(SELECT nextVal(\''.$seqName[0].
'\'))
';
138 }//end handleFunctionSeqNextVal()
152 protected function handleFunctionSeqCurrVal(array $seqName)
154 $sql = '(SELECT currVal(\
''.$seqName[0].
'\'))
';
157 }//end handleFunctionSeqCurrVal()
168 public function handleFunctionSequenceExists($sequenceName)
170 if (is_array($sequenceName) === TRUE) {
171 $sequenceName = $sequenceName[0];
174 $sql = 'SELECT count(c.relname) FROM pg_catalog.pg_class c, pg_catalog.pg_roles r, pg_catalog.pg_namespace n
175 WHERE r.oid = c.relowner AND n.oid = c.relnamespace AND c.relkind = \
'S\'
176 AND n.nspname <> \'pg_catalog\'
177 AND pg_catalog.pg_table_is_visible(c.oid)
178 AND c.relname = '.$sequenceName;
195 $sql = implode(
' || ', $args);
215 $sql =
'TO_TIMESTAMP('.$iso8601_date.
', \'YYYY-MM-DD HH24:MI:SS\')';
249 if (is_array($tableName) === TRUE) {
250 $tableName = $tableName[0];
253 if ($schema === NULL) {
254 $schema =
'\''.DAL::getDbName().
'\'';
257 $sql =
'SELECT count(*) FROM INFORMATION_SCHEMA.tables WHERE TABLE_NAME = '.$tableName.
' AND TABLE_SCHEMA = \'public\' AND TABLE_CATALOG = '.$schema;