orderingMirror=\'' . $wo->db->escape(trim($de['orderingMirror' . $c])) . '\', searchingMirror=\'' . $wo->db->escape(trim($de['searchingMirror' . $c])) . '\', resizeWidth=\'' . $wo->db->escape(trim($de['resizeWidth' . $c])) . '\', resizeHeight=\'' . $wo->db->escape(trim($de['resizeHeight' . $c])) . '\', thumbnailWidth=\'' . $wo->db->escape(trim($de['thumbnailWidth' . $c])) . '\', thumbnailHeight=\'' . $wo->db->escape(trim($de['thumbnailHeight' . $c])) . '\', midSizeColumn=\'' . $wo->db->escape(trim($de['midSizeColumn' . $c])) . '\', midSizeWidth=\'' . $wo->db->escape(trim($de['midSizeWidth' . $c])) . '\', midSizeHeight=\'' . $wo->db->escape(trim($de['midSizeHeight' . $c])) . '\', thumbnailColumn=\'' . $wo->db->escape(trim($de['thumbnailColumn' . $c])) . '\', ordering=\'' . $wo->db->escape(trim($de['ordering' . $c])) . '\', adminCSS=\'' . $wo->db->escape(trim($_POST['adminCSS' . $c])) . '\', indexParticipation=\'' . $wo->db->escape(trim($_POST['indexParticipation' . $c])) . '\', colCollation=\'' . $wo->db->escape(trim($_POST['colCollation' . $c])) . '\' '); $query = 'ALTER TABLE ' . $table->getTableName() . ' ADD COLUMN ' . $wo->db->escape(trim($de['name'] . $_GET['suplec'])) . ' ' . WOOOF_dataBaseColumnTypes::getColumnTypeLiteral($wo->db->escape(trim($de['type' . $c]))); if ($wo->db->escape(trim($de['length' . $c])) != '') { $query .= '(' . $wo->db->escape(trim($de['length' . $c])) . ')'; } if ($wo->db->escape(trim($de['notNull' . $c])) == '1') { $query .= ' NOT NULL '; } if ($wo->hasContent($wo->db->escape(trim($de['defaultValue' . $c])))) { $query .= ' DEFAULT \'' . $wo->db->escape(trim($de['defaultValue' . $c])) . '\''; } if ($wo->hasContent($wo->db->escape(trim($de['colCollation' . $c])))) { $query .= ' COLLATE \'' . $wo->db->escape(trim($de['colCollation' . $c])) . '\''; } //echo $query .'<br/>'; $wo->db->query($query); }
public function updateMetaDataFromPost() { $c = ''; // TODO: What was $c ???? if ($this->currentUserCanChangeProperties) { if (!isset($_POST['notNull']) || $_POST['notNull'] != '1') { $_POST['notNull'] = '0'; } if (!isset($_POST['isReadOnly']) || $_POST['isReadOnly'] != '1') { $_POST['isReadOnly'] = '0'; } if (!isset($_POST['isInvisible']) || $_POST['isInvisible'] != '1') { $_POST['isInvisible'] = '0'; } if (!isset($_POST['isASearchableProperty']) || $_POST['isASearchableProperty'] != '1') { $_POST['isASearchableProperty'] = '0'; } if (!isset($_POST['isReadOnlyAfterFirstUpdate']) || $_POST['isReadOnlyAfterFirstUpdate'] != '1') { $_POST['isReadOnlyAfterFirstUpdate'] = '0'; } if (!isset($_POST['isForeignKey']) || $_POST['isForeignKey'] != '1') { $_POST['isForeignKey'] = '0'; } if (!isset($_POST['appearsInLists']) || $_POST['appearsInLists'] != '1') { $_POST['appearsInLists'] = '0'; } $query = 'update __columnMetaData set name=\'' . $this->dataBase->escape(trim($_POST['name'])) . '\', description=\'' . $this->dataBase->escape(trim($_POST['description'])) . '\', type=\'' . $this->dataBase->escape(trim($_POST['type'])) . '\', length=\'' . $this->dataBase->escape(trim($_POST['length'])) . '\', presentationType=\'' . $this->dataBase->escape(trim($_POST['presentationType'])) . '\', isReadOnly=\'' . $this->dataBase->escape(trim($_POST['isReadOnly'])) . '\', notNull=\'' . $this->dataBase->escape(trim($_POST['notNull'])) . '\', isInvisible=\'' . $this->dataBase->escape(trim($_POST['isInvisible'])) . '\', appearsInLists=\'' . $this->dataBase->escape(trim($_POST['appearsInLists'])) . '\', isASearchableProperty=\'' . $this->dataBase->escape(trim($_POST['isASearchableProperty'])) . '\', isReadOnlyAfterFirstUpdate=\'' . $this->dataBase->escape(trim($_POST['isReadOnlyAfterFirstUpdate'])) . '\', isForeignKey=\'' . $this->dataBase->escape(trim($_POST['isForeignKey'])) . '\', presentationParameters=\'' . $this->dataBase->escape(trim($_POST['presentationParameters'])) . '\', valuesTable=\'' . $this->dataBase->escape(trim($_POST['valuesTable'])) . '\', columnToShow=\'' . $this->dataBase->escape(trim($_POST['columnToShow'])) . '\', columnToStore=\'' . $this->dataBase->escape(trim($_POST['columnToStore'])) . '\', defaultValue=\'' . $this->dataBase->escape(trim($_POST['defaultValue'])) . '\', orderingMirror=\'' . $this->dataBase->escape(trim($_POST['orderingMirror'])) . '\', searchingMirror=\'' . $this->dataBase->escape(trim($_POST['searchingMirror'])) . '\', resizeWidth=\'' . $this->dataBase->escape(trim($_POST['resizeWidth'])) . '\', resizeHeight=\'' . $this->dataBase->escape(trim($_POST['resizeHeight'])) . '\', thumbnailWidth=\'' . $this->dataBase->escape(trim($_POST['thumbnailWidth'])) . '\', thumbnailHeight=\'' . $this->dataBase->escape(trim($_POST['thumbnailHeight'])) . '\', midSizeColumn=\'' . $this->dataBase->escape(trim($_POST['midSizeColumn' . $c])) . '\', midSizeWidth=\'' . $this->dataBase->escape(trim($_POST['midSizeWidth' . $c])) . '\', midSizeHeight=\'' . $this->dataBase->escape(trim($_POST['midSizeHeight' . $c])) . '\', thumbnailColumn=\'' . $this->dataBase->escape(trim($_POST['thumbnailColumn'])) . '\', ordering=\'' . $this->dataBase->escape(trim($_POST['ordering'])) . '\', adminCSS=\'' . $this->dataBase->escape(trim($_POST['adminCSS'])) . '\', indexParticipation=\'' . $this->dataBase->escape(trim($_POST['indexParticipation'])) . '\', colCollation=\'' . $this->dataBase->escape(trim($_POST['colCollation'])) . '\' where id=\'' . $this->columnId . '\''; $succ = $this->dataBase->query($query); if ($succ === FALSE) { return FALSE; } $result = $this->dataBase->query('select tableName from __tableMetaData where id=\'' . $this->tableId . '\''); $temp = $this->dataBase->fetchRow($result); $tableName = $temp[0]; if ($_POST['isForeignKey'] == '1') { $foreignKeyExists = FALSE; $result = $this->dataBase->query('SHOW INDEX FROM ' . $tableName); while ($row = $this->dataBase->fetchAssoc($result)) { if ($row['Key_name'] == 'FK_' . $tableName . '_' . $this->name) { $foreignKeyExists = TRUE; } } if ($foreignKeyExists) { $this->dataBase->query('DROP FOREIGN KEY FK_' . $tableName . '_' . $this->name); } $this->dataBase->query('ALTER TABLE ' . $tableName . ' ADD FOREIGN KEY FK_' . $tableName . '_' . $this->dataBase->escape(trim($_POST['name'])) . ' REFERENCES ' . $this->dataBase->escape(trim($_POST['valuesTable'])) . ' (' . $this->dataBase->escape(trim($_POST['columnToStore'])) . ') ON DELETE RESTRICT ON UPDATE CASCADE'); } if (!$this->belongsToView) { $query = 'ALTER TABLE ' . $tableName . ' CHANGE COLUMN ' . $this->name . ' ' . $this->dataBase->escape(trim($_POST['name'])) . ' ' . WOOOF_dataBaseColumnTypes::getColumnTypeLiteral($this->dataBase->escape(trim($_POST['type']))); if ($this->dataBase->escape(trim($_POST['length'])) != '') { $query .= '(' . $this->dataBase->escape(trim($_POST['length'])) . ')'; } if ($this->dataBase->escape(trim($_POST['notNull'])) == '1') { $query .= ' NOT NULL '; } if (WOOOF::$instance->hasContent($this->dataBase->escape(trim($_POST['defaultValue'])))) { $query .= ' DEFAULT \'' . $this->dataBase->escape(trim($_POST['defaultValue'])) . '\''; } if ($this->dataBase->escape(trim($_POST['colCollation']))) { $query .= ' COLLATE \'' . $this->dataBase->escape(trim($_POST['colCollation'])) . '\''; } $succ = $this->dataBase->query($query); if ($succ === FALSE) { return FALSE; } } // normal table column } else { echo 'FAILED !!! You don\'t have the required rights!'; exit; } return TRUE; }
private static function columnSpec($cmdRow) { $wo = WOOOF::$instance; $res = WOOOF_dataBaseColumnTypes::getColumnTypeLiteral($cmdRow['type']); if ($cmdRow['length'] != '') { $res .= '(' . $cmdRow['length'] . ')'; } if ($wo->hasContent($wo->getFromArray($cmdRow, 'colCollation'))) { $res .= " COLLATE " . $cmdRow['colCollation']; } if ($wo->hasContent($cmdRow['defaultValue'])) { $res .= ' DEFAULT \'' . $cmdRow['defaultValue'] . '\''; } if ($cmdRow['notNull'] == '1') { $res .= ' NOT NULL '; } return $res; }
while ($row = $wo->db->fetchAssoc($result)) { if ($row['Key_name'] == 'FK_' . $t->getTableName() . '_' . $wo->db->escape(trim($_POST['name' . $c]))) { $foreignKeyExists = TRUE; } } if ($foreignKeyExists) { $wo->db->query('DROP FOREIGN KEY FK_' . $t->getTableName() . '_' . $wo->db->escape(trim($_POST['name' . $c]))); } $succ = $wo->db->query('ALTER TABLE ' . $t->getTableName() . ' ADD FOREIGN KEY FK_' . $t->getTableName() . '_' . $wo->db->escape(trim($_POST['name' . $c])) . ' REFERENCES ' . $wo->db->escape(trim($_POST['valuesTable' . $c])) . ' (' . $wo->db->escape(trim($_POST['columnToStore' . $c])) . ') ON DELETE RESTRICT ON UPDATE CASCADE'); } if ($succ === FALSE) { $wo->handleShowStopperError(); } $query = 'ALTER TABLE ' . $t->getTableName() . ' ADD COLUMN ' . $wo->db->escape(trim($_POST['name' . $c])) . ' ' . WOOOF_dataBaseColumnTypes::getColumnTypeLiteral($wo->db->escape(trim($_POST['type' . $c]))); if ($wo->db->escape(trim($_POST['length' . $c])) != '') { $query .= '(' . $wo->db->escape(trim($_POST['length' . $c])) . ')'; } if ($wo->db->escape(trim($_POST['notNull' . $c])) == '1') { $query .= ' NOT NULL '; } if ($wo->hasContent($wo->db->escape(trim($_POST['defaultValue' . $c])))) { $query .= ' DEFAULT \'' . $wo->db->escape(trim($_POST['defaultValue' . $c])) . '\''; } if ($wo->hasContent($wo->db->escape(trim($_POST['colCollation' . $c])))) { $query .= ' COLLATE \'' . $wo->db->escape(trim($_POST['colCollation' . $c])) . '\''; } $succ = $wo->db->query($query); if ($succ === FALSE) { $wo->handleShowStopperError();