[Vtigercrm-commits] [vtiger-commits] r3931 - in /vtigercrm/branches/4.2/adodb: adodb-datadict.inc.php adodb-xmlschema.inc.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Feb 24 23:20:40 EST 2006
Author: mfedyk
Date: Fri Feb 24 21:20:38 2006
New Revision: 3931
Log:
port constraints & table type hack for AXMLS from 4.55 to 4.72. close #33
Modified:
vtigercrm/branches/4.2/adodb/adodb-datadict.inc.php
vtigercrm/branches/4.2/adodb/adodb-xmlschema.inc.php
Modified: vtigercrm/branches/4.2/adodb/adodb-datadict.inc.php
==============================================================================
--- vtigercrm/branches/4.2/adodb/adodb-datadict.inc.php (original)
+++ vtigercrm/branches/4.2/adodb/adodb-datadict.inc.php Fri Feb 24 21:20:38 2006
@@ -1,5 +1,4 @@
<?php
-
/**
V4.72 21 Feb 2006 (c) 2000-2006 John Lim (jlim at natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
@@ -257,6 +256,27 @@
return $this->NameQuote($name);
}
+ // temporary for debuging vtiger - GS
+
+ function println($msg)
+ {
+ require_once('include/logging.php');
+ $log1 =& LoggerManager::getLogger('VT');
+ if(is_array($msg))
+ {
+ $log1->fatal("Install ->".print_r($msg,true));
+ }
+ else
+ {
+ $log1->fatal("Install ->".$msg);
+ }
+ return $msg;
+ }
+
+
+//----------------
+
+
// Executes the sql array returned by GetTableSQL and GetIndexSQL
function ExecuteSQLArray($sql, $continueOnError = true)
{
@@ -266,10 +286,18 @@
foreach($sql as $line) {
if ($this->debug) $conn->debug = true;
+ $this->println($line);
$ok = $conn->Execute($line);
$conn->debug = $saved;
if (!$ok) {
- if ($this->debug) ADOConnection::outp($conn->ErrorMsg());
+ $this->println("Table Creation Error: Query Failed");
+ $this->println(" ");
+ if ($this->debug)
+ {
+
+ $this->println("InstallError: ".$conn->ErrorMsg());
+ ADOConnection::outp($conn->ErrorMsg());
+ }
if (!$continueOnError) return 0;
$rez = 1;
}
@@ -709,7 +737,7 @@
This function changes/adds new fields to your table. You don't
have to know if the col is new or not. It will check on its own.
*/
- function ChangeTableSQL($tablename, $flds, $tableoptions = false)
+ function ChangeTableSQL($tablename, $flds, $tableoptions = false, $forceAlter = false) // GS Fix for constraint impl - forceAlter
{
global $ADODB_FETCH_MODE;
@@ -726,7 +754,7 @@
if (isset($savem)) $this->connection->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ( empty($cols)) {
+ if ( $forceAlter == false && empty($cols)) { // GS Fix for constraint impl
return $this->CreateTableSQL($tablename, $flds, $tableoptions);
}
@@ -778,7 +806,33 @@
}
}
- return $sql;
+ // GS Fix for constraint impl -- start
+ if($forceAlter == false) return $sql;
+ $sqlarray = array();
+
+ $alter .= implode(",\n", $sql);
+ if (sizeof($pkey)>0) {
+ $alter .= ",\n PRIMARY KEY (";
+ $alter .= implode(", ",$pkey).")";
+ }
+
+ if (isset($tableoptions['CONSTRAINTS']))
+ $alter .= "\n".$tableoptions['CONSTRAINTS'];
+
+ if (isset($tableoptions[$this->upperName.'_CONSTRAINTS']))
+ $alter .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS'];
+
+ if (isset($tableoptions[$this->upperName])) $alter .= $tableoptions[$this->upperName];
+ $sqlarray[] = $alter;
+
+
+ $taboptions = $this->_Options($tableoptions);
+ $tsql = $this->_Triggers($this->TableName($tablename),$taboptions);
+ foreach($tsql as $s) $sqlarray[] = $s;
+
+ // GS Fix for constraint impl -- end
+
+ return $sqlarray;
}
} // class
?>
Modified: vtigercrm/branches/4.2/adodb/adodb-xmlschema.inc.php
==============================================================================
--- vtigercrm/branches/4.2/adodb/adodb-xmlschema.inc.php (original)
+++ vtigercrm/branches/4.2/adodb/adodb-xmlschema.inc.php Fri Feb 24 21:20:38 2006
@@ -241,6 +241,7 @@
* @access private
*/
var $drop_field = array();
+ var $alter; // GS Fix for constraint impl
/**
* Iniitializes a new table object.
@@ -251,6 +252,11 @@
function dbTable( &$parent, $attributes = NULL ) {
$this->parent =& $parent;
$this->name = $this->prefix($attributes['NAME']);
+ // GS Fix for constraint impl
+ if(isset($attributes['ALTER']))
+ {
+ $this->alter = $attributes['ALTER'];
+ }
}
/**
@@ -323,12 +329,12 @@
if( isset( $this->current_field ) ) {
$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
} else {
- $this->addTableOpt( $cdata );
+ $this->addTableOpt('CONSTRAINTS', $cdata ); // GS Fix for constraint impl
}
break;
// Table option
case 'OPT':
- $this->addTableOpt( $cdata );
+ $this->addTableOpt('mysql', $cdata ); // GS Fix for constraint impl
break;
default:
@@ -462,8 +468,9 @@
* @param string $opt Table option
* @return array Options
*/
- function addTableOpt( $opt ) {
- $this->opts[] = $opt;
+ function addTableOpt($key, $opt ) { // GS Fix for constraint impl
+ //$this->opts[] = $opt;
+ $this->opts[$key] = $opt;
return $this->opts;
}
@@ -545,7 +552,7 @@
}
}
- if( empty( $legacy_fields ) ) {
+ if( empty( $legacy_fields ) && !isset($this->alter)) { // GS Fix for constraint impl
// Create the new table
$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
logMsg( end( $sql ), 'Generated CreateTableSQL' );
@@ -556,7 +563,7 @@
// Use ChangeTableSQL
case 'ALTER':
logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
- $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
+ $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts, $this->alter ); // GS Fix for constraint impl
break;
case 'REPLACE':
logMsg( 'Doing upgrade REPLACE (testing)' );
@@ -2218,4 +2225,4 @@
echo '</pre>';
}
}
-?>
+?>
More information about the vtigercrm-commits
mailing list