10 defined(
'JPATH_PLATFORM') or die;
29 protected function buildXml()
33 $buffer[] =
'<?xml version="1.0"?>';
34 $buffer[] =
'<postgresqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
35 $buffer[] =
' <database name="">';
37 $buffer = array_merge($buffer, $this->buildXmlStructure());
39 $buffer[] =
' </database>';
40 $buffer[] =
'</postgresqldump>';
42 return implode(
"\n", $buffer);
53 protected function buildXmlStructure()
57 foreach ($this->from as $table)
60 $table = $this->getGenericTableName($table);
63 $fields = $this->db->getTableColumns($table,
false);
64 $keys = $this->db->getTableKeys($table);
65 $sequences = $this->db->getTableSequences($table);
67 $buffer[] =
' <table_structure name="' . $table .
'">';
69 foreach ($sequences as $sequence)
71 if (version_compare($this->db->getVersion(),
'9.1.0') < 0)
73 $sequence->start_value = null;
76 $buffer[] =
' <sequence Name="' . $sequence->sequence .
'"' .
' Schema="' . $sequence->schema .
'"' .
77 ' Table="' . $sequence->table .
'"' .
' Column="' . $sequence->column .
'"' .
' Type="' . $sequence->data_type .
'"' .
78 ' Start_Value="' . $sequence->start_value .
'"' .
' Min_Value="' . $sequence->minimum_value .
'"' .
79 ' Max_Value="' . $sequence->maximum_value .
'"' .
' Increment="' . $sequence->increment .
'"' .
80 ' Cycle_option="' . $sequence->cycle_option .
'"' .
84 foreach ($fields as $field)
86 $buffer[] =
' <field Field="' . $field->column_name .
'"' .
' Type="' . $field->type .
'"' .
' Null="' . $field->null .
'"' .
87 (isset($field->default) ?
' Default="' . $field->default .
'"' :
'') .
' Comments="' . $field->comments .
'"' .
91 foreach ($keys as $key)
93 $buffer[] =
' <key Index="' . $key->idxName .
'"' .
' is_primary="' . $key->isPrimary .
'"' .
' is_unique="' . $key->isUnique .
'"' .
94 ' Query="' . $key->Query .
'" />';
97 $buffer[] =
' </table_structure>';
111 public function check()
116 throw new Exception(
'JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
120 if (empty($this->from))
122 throw new Exception(
'JPLATFORM_ERROR_NO_TABLES_SPECIFIED');