예제 #1
0
 function alterTable($tablename, $newdatadef, $info, $aggressive = false)
 {
     $dd = $this->getDataDefinition($tablename);
     $modified = false;
     if ($aggressive) {
         $oldcols = array_diff_assoc($dd, $newdatadef);
         if (count($oldcols)) {
             $modified = true;
             $sql = "ALTER TABLE `" . $this->prefix . "{$tablename}` ";
             foreach ($oldcols as $name => $def) {
                 $sql .= " DROP COLUMN " . $name . ",";
             }
             $sql = substr($sql, 0, -1);
             @mysql_query($sql, $this->connection);
         }
     }
     $diff = array_diff_assoc($newdatadef, $dd);
     if (count($diff)) {
         $modified = true;
         $sql = "ALTER TABLE `" . $this->prefix . "{$tablename}` ";
         foreach ($diff as $name => $def) {
             $sql .= " ADD COLUMN (" . $this->fieldSQL($name, $def) . "),";
         }
         $sql = substr($sql, 0, -1);
         @mysql_query($sql, $this->connection);
     }
     $return = array($tablename => $modified ? TABLE_ALTER_SUCCEEDED : TABLE_ALTER_NOT_NEEDED);
     if (isset($info[DB_TABLE_WORKFLOW]) && $info[DB_TABLE_WORKFLOW]) {
         // Initialize workflow tables:
         if (!defined("SYS_WORKFLOW")) {
             require_once BASE . "subsystems/workflow.php";
         }
         $wf = exponent_workflow_alterWorkflowTables($tablename, $newdatadef, $aggressive);
         foreach ($wf as $key => $status) {
             $return[$key] = $status;
         }
     }
     return $return;
 }
예제 #2
0
function exponent_workflow_installWorkflowTables($existingname, $tabledef)
{
    return exponent_workflow_alterWorkflowTables($existingname, $tabledef);
}
예제 #3
0
 function alterTable($tablename, $newdatadef, $info, $aggressive = false)
 {
     $dd = $this->getDataDefinition($tablename);
     $modified = false;
     if ($aggressive) {
         $oldcols = array_diff_assoc($dd, $newdatadef);
         if (count($oldcols)) {
             $modified = true;
             foreach ($oldcols as $name => $def) {
                 $sql = "ALTER TABLE " . $this->prefix . $tablename . ' DROP COLUMN "' . $name . '"';
                 pg_query($this->connection, $sql);
             }
         }
     }
     $diff = array_diff_assoc($newdatadef, $dd);
     if (count($diff)) {
         $modified = true;
         foreach ($diff as $name => $def) {
             $sql = 'ALTER TABLE "' . $this->prefix . $tablename . '" ADD COLUMN ' . $this->fieldSQL($name, $def);
             #echo $sql .'<br />';
             pg_query($this->connection, $sql);
         }
     }
     if (isset($info[DB_TABLE_WORKFLOW]) && $info[DB_TABLE_WORKFLOW]) {
         // Initialize workflow tables:
         if (!defined("SYS_WORKFLOW")) {
             require_once BASE . "subsystems/workflow.php";
         }
         exponent_workflow_alterWorkflowTables($tablename, $newdatadef);
     }
     if ($modified) {
         return TABLE_ALTER_SUCCEEDED;
     } else {
         return TABLE_ALTER_NOT_NEEDED;
     }
 }