Add code to check extra_fields and add them to the create spec even if no data existed

This commit is contained in:
Miles Lott 2001-02-22 15:53:38 +00:00
parent dc5e1437f0
commit bdac59038b

View File

@ -335,10 +335,10 @@
while ($this->db2->next_record()) { while ($this->db2->next_record()) {
// If its not in the list to be returned, don't return it. // If its not in the list to be returned, don't return it.
// This is still quicker then 5(+) separate queries // This is still quicker then 5(+) separate queries
if ($extra_fields[$this->db2->f("contact_name")]) {
if (!strstr($tempcreate,$this->db2->f("contact_name"))) { if (!strstr($tempcreate,$this->db2->f("contact_name"))) {
$tempcreate .= $this->db2->f("contact_name") ." TEXT,"; $tempcreate .= $this->db2->f("contact_name") ." TEXT,";
} }
if ($extra_fields[$this->db2->f("contact_name")]) {
$tempinsert[$i] .= $this->db2->f("contact_name").","; $tempinsert[$i] .= $this->db2->f("contact_name").",";
$tempvalues[$i] .= '"'.$this->db2->f("contact_value").'",'; $tempvalues[$i] .= '"'.$this->db2->f("contact_value").'",';
} }
@ -356,7 +356,17 @@
} }
// fixup strings, create and populate temp table of extra fields // fixup strings, create and populate temp table of extra fields
// this section adds the extra_fields to the table
// if no prior data existed (new application, etc.)
if ($extra_fields) {
while (list($name,$value) = each($extra_fields)) {
if (!strstr($tempcreate,$name)) {
$tempcreate .= $name ." TEXT,";
}
}
}
$tempcreate = substr($tempcreate,0,-1) . ")"; $tempcreate = substr($tempcreate,0,-1) . ")";
//echo $tempcreate;
$this->db->query("DROP TABLE IF EXISTS $tmp_table"); $this->db->query("DROP TABLE IF EXISTS $tmp_table");
$this->db->query($tempcreate); $this->db->query($tempcreate);