function dbUpgradeTable

Fragen zur Installation von CONTENIDO 4.9? Probleme bei der Konfiguration? Hinweise oder Fragen zur Entwicklung des Systemes oder zur Sicherheit?
Antworten
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

function dbUpgradeTable

Beitrag von emergence »

das ist ein kleiner split of vom newsletter cvs thread

es fehlt leider die möglichkeit ein db feld umzubennen bei dbUpgradeTable...

und bin auf folgenden ablauf gekommen um das ganze zu implementieren...

der zweite parameter der übergeben wird ist ja $field

man könnte nun definieren das wenn , im string field gefunden wird das eine umbenennung stattfinden soll...

gute oder schlechte idee ?
*** make your own tools (wishlist :: thx)
timo
Beiträge: 6284
Registriert: Do 15. Mai 2003, 18:32
Wohnort: Da findet ihr mich nie!
Kontaktdaten:

Beitrag von timo »

wir haben uns damals intern darauf verständigt, daß es keine Feldumbenennungen geben darf...

Ich hatte das damals (vor fast 1,5 Jahren) auch mitgeplant, aber es gab da irgendwelche Probleme, deshalb wurde das Commitment abgegeben...
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

d.h dann an sich das herrb seine modifiedby in modfied ändern müsste...
oder siehst du ne andere möglichkeit...

die dbUpgradeTable entsprechend umzubauen stellt aber nicht so ein problem dar, denk ich mir zumindestens...

wie gesagt ich würd es einfach mittels , splitten
checken ob das erste feld existiert, falls nicht den zweiten teil in der tabelle anlegen...
falls doch beim alter table $field1 und $field2 verwenden...

sollte ja ganz einfach funktionieren... ;-)
*** make your own tools (wishlist :: thx)
timo
Beiträge: 6284
Registriert: Do 15. Mai 2003, 18:32
Wohnort: Da findet ihr mich nie!
Kontaktdaten:

Beitrag von timo »

gerade da bin ich mir nicht sicher - wenn das wirklich so einfach gehen würde, dann hätte ich das damals auch reingebaut :?:
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

nun ja man müsste die sich die ganzen dinge halt noch etwas überlegen worauf man aufpassen muss... aber soviel kann an sich nicht fehlen...
*** make your own tools (wishlist :: thx)
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

ich hab das jetzt mal etwas umgebaut...

was hälts du davon ?

Code: Alles auswählen

function dbUpgradeTable ($table, $field, $type, $null, $key, $default, $extra, $upgradeStatement)
{
	global $dbupgrade1, $dbupgrade2;
	global $columnCache;
	global $tableCache;

	if (!is_object($dbupgrade1))
	{
		$dbupgrade1 = new DB_Upgrade;
	}

	if (!is_object($dbupgrade2))
	{
		$dbupgrade2 = new DB_Upgrade;
	}

	if(strstr($field, ',')) {
		$renameField = true;
		$fields = explode(",", $field);
		$field1 = $fields[0];
		$field2 = $fields[1];
		unset($fields);
	} else {
		$renameField = false;
	}

	/* Function logic:
	   1 .) Check if the table exists
 	   1a.) If not, create it with the field specification
       2 .) If the table exists:
       2a.) If the field exists and the fields type is matching, exit
       2b.) If the field exists and the field's content type is not matching, try to convert first (e.g. string to int
		    or int to string), then use the upgrade statement if applicable

	   Note about the upgrade statement:
		- the code must be eval'able
		- the code needs to read $oldVal (old field value) and needs to set $newVal (value to which the field will be set)
		- $oldVal might be empty if the field didn't exist
		- $tableValues['fieldname'] contains the already existing values
	*/

	/* Parameter checking for $null
       If parameter is "" or "NULL" or "YES", we know that
	   we want the colum to forbid null entries.
	 */
	if ($null == "NULL" || $null == "YES")
	{
		$parameter['NULL'] = "NULL";
		$null = "YES";
	} else {
		$parameter['NULL'] = "NOT NULL";
		$null = "";
	}

	/* Parameter checking for $key
       If parameter is "" or "NULL" or "YES", we know that
	   we want the primary key.
	 */
	if ($key == "PRI")
	{
		$parameter['KEY'] = "PRIMARY KEY";
	} else {
		$parameter['KEY'] = "";
	}


	/* Parameter check for $default
       If set, create a default value */
	if ($default != "")
	{
		$parameter['DEFAULT'] = "DEFAULT '$default'";
	}



	if (!dbTableExists($table))
	{
		if ($renameField) {
			$field = $field2;
		}
		$createTable = "  CREATE TABLE $table ($field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'] .")";
		$dbupgrade1->query($createTable);
		$tableCache[] = $table;
		return;
	}

	$structure = dbGetColumns($table);
	$savedPrimaryKey = dbGetPrimaryKeyName($table);

	if ($renameField && array_key_exists($field1,$structure) && !array_key_exists($field2,$structure))
	{
		$alterField = "  ALTER TABLE $table CHANGE COLUMN $field1 $field2 $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];
    	$dbupgrade1->query($alterField);
    	$columnCache[$table] = "";
    	return;
	}
	
	if ($renameField) {
	    $field = $field2;
	}

	if (!array_key_exists($field,$structure))
	{
    	$createField = "  ALTER TABLE $table ADD COLUMN $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];
    	$dbupgrade1->query($createField);
    	$columnCache[$table] = "";
    	return;
	}

	/* Third check: Compare field properties */
	if (($structure[$field]['Type'] != $type) ||
	    ($structure[$field]['Null'] != $null) ||
	    ($structure[$field]['Key'] != $key) ||
	    ($structure[$field]['Default'] != $default) ||
	    ($structure[$field]['Extra'] != $extra))
	{

		if ($structure[$field]['Key'] == "PRI")
		{
			return "The primary key is not allowed to change";
		}

		if ($structure[$field]['Key'] == "MUL")
		{
			return;
		}

		$alterField = "  ALTER TABLE $table CHANGE COLUMN $field $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];

		$dbupgrade1->query($alterField);
		$columnCache[$table] = "";

	}


}
*** make your own tools (wishlist :: thx)
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

der aufruf müsste in der upgrade.php dann so aussehen

dbUpgradeTable($prefix."_news", 'lastmodified,modified', 'datetime', '', '', '0000-00-00 00:00:00', '','');
und
dbUpgradeTable($prefix."_news_rcp", 'lastmodified,modified', 'datetime', '', '', '0000-00-00 00:00:00', '','');

zur erklärung
es wird überprüft ob in $field ein , vorkommt
das ganze wird gesplittet in die variablen $field1 und $field2 und die variable $renameField wird auf true gesetzt.

dann wird kontrolliert ob die tabelle exisitiert, falls nicht wird überprüft ob $renameField true ist $field wird auf $field2 gesetzt und das statement wird ausgeführt...

falls die tabelle existiert wird kontrolliert ob $renameField true $field1 existiert und $field2 nicht existiert wenn das zutrifft wird die tabelle umbenannt...

falls renameField true ist und obriger teil wurde nicht ausgeführt wird $field der wert $field2 zugewiesen...

dürfte an sich nichts daneben gehen...
*** make your own tools (wishlist :: thx)
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Na toll, eigentlich war mir nur so, als hätte emergence bereits etwas gepostet, dass in der setup\index.php mal auf 'update' statt 'upgrade' geprüft wird - suche also nach Upgrade und finde dieses Thema (welches ich komplett übersehen habe)...

Ach ja, wie soll ich es sagen, ich habe nun in 6 Stunden das gleiche nochmal programmiert und wollte es freudestrahlend präsentieren... :roll:

Nun, jedenfalls weiss ich jetzt im Groben, wie das Setup funktioniert, auch was Feines... :wink:

Damit es nicht ganz umsonst war, anbei noch meine Lösung. Gegenüber emergence' Lösung hat sie den Nachteil, dass ein zusätzlicher Parameter eingeführt wird (ja, die Idee mit der Angabe der Altnamen im gleichen Feld ist gut - dann braucht man auch die dbDumpStructure nicht überarbeiten).

Als Vorteil kann man bei meiner Lösung auch mehrere Altnamen angeben (-> Upgrade von Version x, y, z möglich) - das kann man ja leicht noch ergänzen. Auch führt meine Lösung nur die Umbenennung der Spalte durch - die restliche Spezifikation (z.B. Spaltentyp) wird im Gegensatz zur Version von emergence zunächst nicht verändert (es werden die Angaben aus dem $structure-Array verwendet und nicht aus dem $parameter-Array). Damit ist verhindert, dass eine Änderung, die gemäß "Third check" nicht möglich wäre, nicht aus Versehen beim Umbenennen schon durchgeführt wird.

Sollte es doch Bedarf geben, stelle ich gerne die angepasste upgrade.php zur Verfügung.

Code: Alles auswählen

function dbUpgradeTable ($table, $field, $previousName, $type, $null, $key, $default, $extra, $upgradeStatement)
{
	global $dbupgrade1, $dbupgrade2;
	global $columnCache;
	global $tableCache;
	
	if (!is_object($dbupgrade1))
	{
		$dbupgrade1 = new DB_Upgrade;
	}
	
	if (!is_object($dbupgrade2))
	{
		$dbupgrade2 = new DB_Upgrade;
	}

	/* Function logic:
	   1 .) Check, if the table exists
 	   2a.) If not, create it with the field specification, exit
           2b.) If the table exists, check, if the field exist
           3 .) If not, try to find the field using $previousname (= "name1,name2")
           4a.) If the field haven't been found, create the field as specified, exit
           4b.) If the field has been found using $previousname rename the column to $field
           5 .) As the field has been found, check, if the field's type is matching
           5a.) If the type is matching, exit
           5b.) If the field's content type is not matching, try to convert first (e.g. string to int
		or int to string), then use the upgrade statement if applicable
	
	   Note about the upgrade statement:
		- the code must be eval'able
		- the code needs to read $oldVal (old field value) and needs to set $newVal (value to which the field will be set)
		- $oldVal might be empty if the field didn't exist
		- $tableValues['fieldname'] contains the already existing values
	*/

	/* Parameter checking for $null
       If parameter is "" or "NULL" or "YES", we know that
	   we want the colum to forbid null entries.
	 */ 
	if ($null == "NULL" || $null == "YES")
	{
		$parameter['NULL'] = "NULL";
		$null = "YES";
	} else {
		$parameter['NULL'] = "NOT NULL";
		$null = "";
	}

	/* Parameter checking for $key
       If parameter is "" or "NULL" or "YES", we know that
	   we want the primary key.
	 */	
	if ($key == "PRI")
	{
		$parameter['KEY'] = "PRIMARY KEY";
	} else {
		$parameter['KEY'] = "";
	}
	
	
	/* Parameter check for $default
       If set, create a default value */
	if ($default != "")
	{
		$parameter['DEFAULT'] = "DEFAULT '$default'";
	}
	
	if (!dbTableExists($table))
	{
		$createTable = "  CREATE TABLE $table ($field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'] .")";
		$dbupgrade1->query($createTable);
		$tableCache[] = $table;
		return;						
	} 
	
	$structure = dbGetColumns($table);
	$savedPrimaryKey = dbGetPrimaryKeyName($table); /* ? */
		
	if (!array_key_exists($field,$structure))
	{
		/* HerrB: Search field using $previousName */
		$blnFound = false;
                if ($previousName != "") {
			$arrPreviousName = explode(",", $previousName);
			foreach ($arrPreviousName as $strPrevious) {
				$strPrevious = trim($strPrevious);
				if (array_key_exists($strPrevious,$structure)) {
					$blnFound = true;
					break;
				}
			}
		}

		if ($blnFound) {
			/* Rename column, update array, proceed */
			if ($structure[$strPrevious]['Null'] == 'YES') {
				$alterField = "  ALTER TABLE `$table` CHANGE COLUMN `$strPrevious` `$field` ".$structure[$strPrevious]['Type']." DEFAULT '".$structure[$strPrevious]['Default']."'";
			} else {
				$alterField = "  ALTER TABLE `$table` CHANGE COLUMN `$strPrevious` `$field` ".$structure[$strPrevious]['Type']." NOT NULL DEFAULT '".$structure[$strPrevious]['Default']."'";
			}
		    	$dbupgrade1->query($alterField);
			$columnCache[$table] = "";
			$structure = dbGetColumns($table);
		} else {
			/* Add column as specified */
    			$createField = "  ALTER TABLE $table ADD COLUMN $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];
		    	$dbupgrade1->query($createField);
		    	$columnCache[$table] = "";
		    	return;
		}
	}

	/* Third check: Compare field properties */
	if (($structure[$field]['Type'] != $type) ||
	    ($structure[$field]['Null'] != $null) ||
	    ($structure[$field]['Key'] != $key) ||
	    ($structure[$field]['Default'] != $default) ||
	    ($structure[$field]['Extra'] != $extra))
	{
		
		if ($structure[$field]['Key'] == "PRI")
		{
			return "The primary key is not allowed to change";
		}
		
		if ($structure[$field]['Key'] == "MUL")
		{
			return;
		}
		
		$alterField = "  ALTER TABLE $table CHANGE COLUMN $field $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];

		$dbupgrade1->query($alterField);
		$columnCache[$table] = "";	
	}
}
Und eine Frage habe ich noch: Aus der functions.database.php könnte wohl noch einiges raus, oder? dbUpgrade2 wird z.B. IMHO nirgends verwendet und $savedPrimaryKey = dbGetPrimaryKeyName($table); wohl auch nicht...

Ach ja und man kann zwar einen Primary oder Multiple Key einführen, ihn jedoch nicht mehr zurücknehmen, denke ich.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

HerrB hat geschrieben:Ach ja, wie soll ich es sagen, ich habe nun in 6 Stunden das gleiche nochmal programmiert und wollte es freudestrahlend präsentieren... :roll:
das tut mir leid, hätte dir auch ne nachricht schicken können...
Damit es nicht ganz umsonst war, anbei noch meine Lösung. Gegenüber emergence' Lösung hat sie den Nachteil, dass ein zusätzlicher Parameter eingeführt wird (ja, die Idee mit der Angabe der Altnamen im gleichen Feld ist gut - dann braucht man auch die dbDumpStructure nicht überarbeiten).
nicht nur das, da müsste man noch sämtliche updatescript mit ausbessern... zb die upgrade.php und ich denk mir da das ist doch etwas high risk...
Auch führt meine Lösung nur die Umbenennung der Spalte durch - die restliche Spezifikation (z.B. Spaltentyp) wird im Gegensatz zur Version von emergence zunächst nicht verändert (es werden die Angaben aus dem $structure-Array verwendet und nicht aus dem $parameter-Array). Damit ist verhindert, dass eine Änderung, die gemäß "Third check" nicht möglich wäre, nicht aus Versehen beim Umbenennen schon durchgeführt wird.
mit der idee das zu berücksichtigen hab ich schon gespielt...
aber ich weiss nicht ob eine umbenennung eines primary keys wertes überhaupt gemacht werden sollte... lt. third check wird ja nichts gemacht, genauso wie bei multiple...
Und eine Frage habe ich noch: Aus der functions.database.php könnte wohl noch einiges raus, oder? dbUpgrade2 wird z.B. IMHO nirgends verwendet und $savedPrimaryKey = dbGetPrimaryKeyName($table); wohl auch nicht...
da hast du recht, so wie es aussieht werden diese punkte nicht benötigt...

na wie auch immer, elegant implementierbar ist das sicherlich, die offenen fragen müssten halt noch geklärt werden... das mit einer kleinen aufräum aktion zu kombinieren wird auch noch drinnen sein ;-)

auszahlen tut sich das ganze wirklich nur wenn das in den cvs_head übernommen wird... da müsste 4fb noch was dazu sagen...
*** make your own tools (wishlist :: thx)
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

das tut mir leid, hätte dir auch ne nachricht schicken können...
Hey, das war kein Vorwurf, um Himmels willen - ich meinte mich; hätte auch mal vorher gucken können...
nicht nur das, da müsste man noch sämtliche updatescript mit ausbessern
Ach, die upgrade.php hätte ich da, ich musste das Ganze ja testen (bevor ich in das Forum geuckt habe :twisted: ). Aber ich finde Deine Lösung besser, nur würde ich den Zielnamen an die erste Stelle setzen und mehrere weitere erlauben.

Tja, timo, unsere Lösung wäre dann ja sogar optional - keine Probleme, wenn man keine Alternativnamen angibt.

Gruß
HerrB

P.S.:
Irgendwie könnte man diesen Teil auch überarbeiten... :wink:

Code: Alles auswählen

if ($structure[$field]['Key'] == "PRI")
      {
         return "The primary key is not allowed to change";
      }
      
      if ($structure[$field]['Key'] == "MUL")
      {
         return;
      }
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

So, das wäre das Beste aus zwei Welten (nun ja). Getestet habe ich es, aber ein Code-Review durch jemand anderen ist vermutlich eine gute Idee.

Ich habe auch die Funktionserläuterung angepasst, sie hatte es nötig. Die z.Z. verwendete Version unternimmt übrigens keinen Konvertierungsversuch, sondern überlässt die Arbeit mySQL - aber den Satz habe ich drin gelassen, klingt doch schöner... :wink:

Code: Alles auswählen

function dbUpgradeTable ($table, $field, $type, $null, $key, $default, $extra, $upgradeStatement) {
	global $dbupgrade1;  // HerrB: not used: , $dbupgrade2;
	global $columnCache;
	global $tableCache;
	
	if (!is_object($dbupgrade1)) {
		$dbupgrade1 = new DB_Upgrade;
	}
	
	/* HerrB: Not used */
	/* if (!is_object($dbupgrade2)) {
		$dbupgrade2 = new DB_Upgrade;
	} */

	/* Function logic:
	*  1 .) Check, if the table exists
 	*  2a.) If not, create it with the field specification, exit
        *  2b.) If the table exists, check, if the field exist
        *  3 .) If not, try to find the field using previous names (if specified in $field like "name1,name2")
        *  4a.) If the field hasn't been found, create the field as specified, exit
        *  4b.) If the field has been found using a previous name (if specified) rename the column to $field
        *  5 .) As the field has been found, check, if the field's type is matching
        *  5a.) If the type is matching, exit
        *  5b.) If the field's content type is not matching, try to convert first (e.g. string to int
	*	or int to string), then use the upgrade statement if applicable
	*
	*  Note about the upgrade statement:
	*	- the code must be eval'able
	*	- the code needs to read $oldVal (old field value) and needs to set $newVal (value to which the field will be set)
	*	- $oldVal might be empty if the field didn't exist
	*	- $tableValues['fieldname'] contains the already existing values */

	/* Parameter checking for $null
	*  If parameter is "" or "NULL" or "YES", we know that
	*  we want the colum to forbid null entries. */ 
	if ($null == "NULL" || $null == "YES") {
		$parameter['NULL'] = "NULL";
		$null = "YES";
	} else {
		$parameter['NULL'] = "NOT NULL";
		$null = "";
	}

	/* Parameter checking for $key
	*  If parameter is "" or "NULL" or "YES", we know that
	*  we want the primary key. */	
	if ($key == "PRI") {
		$parameter['KEY'] = "PRIMARY KEY";
	} else {
		$parameter['KEY'] = "";
	}
	
	/* Parameter check for $default
	*  If set, create a default value */
	if ($default != "") {
		$parameter['DEFAULT'] = "DEFAULT '$default'";
	}
	
	if (!dbTableExists($table)) {
		$createTable = "  CREATE TABLE $table ($field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'] .")";
		$dbupgrade1->query($createTable);
		$tableCache[] = $table;
		return;						
	} 
	
	$structure = dbGetColumns($table);
	// $savedPrimaryKey = dbGetPrimaryKeyName($table); /* HerrB: Nowhere used */

	/* If $field contains "," previous names has been specified; separate from $field */
	$sepPos = strpos($field, ",");
	if ($sepPos === false) {
		$previousName = "";
	} else {
		$previousName = substr($field, $sepPos + 1);
		$field = substr($field, 0, $sepPos);
	}
		
	if (!array_key_exists($field,$structure)) {
		/* HerrB: Search field using $previousName */
		$blnFound = false;
                if ($previousName != "") {
			$arrPreviousName = explode(",", $previousName);
			foreach ($arrPreviousName as $strPrevious) {
				$strPrevious = trim($strPrevious); // Maybe someone has used field1, field2, ..., trim spaces
				if (array_key_exists($strPrevious,$structure)) {
					$blnFound = true;
					break;
				}
			}
		}

		if ($blnFound) {
			/* Rename column, update array, proceed */
			if ($structure[$strPrevious]['Null'] == 'YES') {
				$alterField = "  ALTER TABLE `$table` CHANGE COLUMN `$strPrevious` `$field` ".$structure[$strPrevious]['Type']." DEFAULT '".$structure[$strPrevious]['Default']."'";
			} else {
				$alterField = "  ALTER TABLE `$table` CHANGE COLUMN `$strPrevious` `$field` ".$structure[$strPrevious]['Type']." NOT NULL DEFAULT '".$structure[$strPrevious]['Default']."'";
			}
		    	$dbupgrade1->query($alterField);
			$columnCache[$table] = "";
			$structure = dbGetColumns($table);
		} else {
			/* Add column as specified */
    			$createField = "  ALTER TABLE $table ADD COLUMN $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];
		    	$dbupgrade1->query($createField);
		    	$columnCache[$table] = "";
		    	return;
		}
	}

	/* Third check: Compare field properties */
	if (($structure[$field]['Type'] != $type) ||
	    ($structure[$field]['Null'] != $null) ||
	    ($structure[$field]['Key'] != $key) ||
	    ($structure[$field]['Default'] != $default) ||
	    ($structure[$field]['Extra'] != $extra)) {
		
		if ($structure[$field]['Key'] == "PRI") {
			return "The primary key is not allowed to change";
		}
		
		if ($structure[$field]['Key'] == "MUL") {
			return;
		}

		/* HerrB: So ... this would it do, too, but maybe there is a reason ...
		if ($structure[$field]['Key'] == "PRI" || $structure[$field]['Key'] == "MUL") {
			return "Primary or multiple key is not allowed to change";
		} */
		
		$alterField = "  ALTER TABLE $table CHANGE COLUMN $field $field $type ".$parameter['NULL']." ".$parameter['DEFAULT']." ".$parameter['KEY'];

		$dbupgrade1->query($alterField);
		$columnCache[$table] = "";
	}
}
Einige Zeilen habe ich auskommentiert, da sie in der Funktion nicht verwendet und keine Subroutinen aufgerufen werden - das kann dann wohl weg.

Das bei der Abfrage auf Multiple Keys keine Rückgabe stattfindet, hat vielleicht einen Grund, ansonsten könnte man die angegeben Abfrage übernehmen.

Hat das eigentlich einen spezifischen Grund, warum die SQL-Statements alle mit zwei Leerzeichen anfangen?

Die entsprechenden Zeilen in der dbUpgrade.php müssten dann so lauten:

Code: Alles auswählen

dbUpgradeTable($prefix."_news", 'modified,lastmodified', 'datetime', '', '', '0000-00-00 00:00:00', '','');
...
dbUpgradeTable($prefix."_news_rcp", 'modified,lastmodified', 'datetime', '', '', '0000-00-00 00:00:00', '','');
Ist kein Komma enthalten, wird nur nach $field gesucht (Zielname). Ist ein Komma enthalten, entspricht der erste Name dem Zielnamen, alle weiteren sind Alias- bzw. alte Namen. Ggf. angefügte Leerzeichen werden entfernt (z.B. vor name2 bei "name1, name2,...").

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
Antworten