protected function createRevision() {
$indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
- foreach($this->objects as $object) {
+ foreach ($this->objects as $object) {
call_user_func(array($this->className, 'createRevision'), array_merge($object->getData(), array($indexName =>$object->__get($indexName))));
}
}
}
// currently we only support restoring one version
- foreach($this->objects as $object) {
+ foreach ($this->objects as $object) {
$objectType = VersionHandler::getInstance()->getObjectTypeByName($object->objectTypeName);
$restoreObject = VersionHandler::getInstance()->getVersionByID($objectType->objectTypeID, $this->parameters['restoreObjectID']);
public static function deleteAll(array $objectIDs = array()) {
$affectedCount = static::deleteAll($objectIDs);
- //delete versions
+ // delete versions
$sql = "DELETE FROM ".static::getDatabaseVersionTableName()."
WHERE ".static::getDatabaseTableIndexName()." = ?";
$statement = WCF::getDB()->prepareStatement($sql);
while ($row = $statement->fetchArray()) {
$typeMatches = Regex::compile('([a-z]+)\(([0-9]+)\)', Regex::CASE_INSENSITIVE)->match($row['Type']);
- $columns[] = array('name' => $row['Field'],
- 'data' => array(
- 'type' => $typeMatches[1],
- 'length' => $typeMatches[2],
- 'notNull' => (($row['Null'] == 'YES') ? true : false),
- 'key' => (($row['Key'] == 'PRI') ? 'PRIMARY' : (($row['Key'] == 'UNI') ? 'UNIQUE' : '')),
- 'default' => $row['Default'],
- 'autoIncrement' => ($row['Extra'] == 'auto_increment' ? true : false)
- )
- );
+ $columns[] = array('name' => $row['Field'], 'data' => array(
+ 'type' => $typeMatches[1],
+ 'length' => $typeMatches[2],
+ 'notNull' => (($row['Null'] == 'YES') ? true : false),
+ 'key' => (($row['Key'] == 'PRI') ? 'PRIMARY' : (($row['Key'] == 'UNI') ? 'UNIQUE' : '')),
+ 'default' => $row['Default'],
+ 'autoIncrement' => ($row['Extra'] == 'auto_increment' ? true : false)
+ ));
}
return $columns;
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute(array($tableName));
while ($row = $statement->fetchArray()) {
- $columns[] = array('name' => $row['attname'],
- 'data' => array(
- 'type' => $row['typname'],
- 'length' => $row['attlen'],
- 'notNull' => $row['attnotnull'],
- 'key' => (($row['contype'] == 'p') ? 'PRIMARY' : (($row['contype'] == 'u') ? 'UNIQUE' : '')),
- 'default' => $row['adsrc'],
- 'autoIncrement' => ($row['contype'] == 'p')
- )
- );
+ $columns[] = array('name' => $row['attname'], 'data' => array(
+ 'type' => $row['typname'],
+ 'length' => $row['attlen'],
+ 'notNull' => $row['attnotnull'],
+ 'key' => (($row['contype'] == 'p') ? 'PRIMARY' : (($row['contype'] == 'u') ? 'UNIQUE' : '')),
+ 'default' => $row['adsrc'],
+ 'autoIncrement' => ($row['contype'] == 'p')
+ ));
}
return $columns;
// get structure of version table
$versionTableColumns = WCF::getDB()->getEditor()->getColumns($objectType::getDatabaseVersionTableName());
- if (empty($versionTableColumns)){
+ if (empty($versionTableColumns)) {
$columns = array_merge($versionTableBaseColumns, $baseTableColumns);
WCF::getDB()->getEditor()->createTable($objectType::getDatabaseVersionTableName(), $columns);