mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge remote-tracking branch 'origin/2.4' into 3.0
Conflicts: README.md composer.json docs/en/installation/from-source.md docs/en/misc/contributing.md model/Database.php
This commit is contained in:
commit
79cf1faf53
@ -1,6 +1,6 @@
|
||||
## SilverStripe Framework
|
||||
|
||||
[![Build Status](https://secure.travis-ci.org/silverstripe/sapphire.png?branch=3.0)](https://travis-ci.org/silverstripe/sapphire)
|
||||
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-framework.png?branch=3.0)](https://travis-ci.org/silverstripe/silverstripe-framework)
|
||||
|
||||
PHP5 framework forming the base for the SilverStripe CMS ([http://silverstripe.org](http://silverstripe.org)).
|
||||
Requires a [`silverstripe-installer`](http://github.com/silverstripe/silverstripe-installer) base project. Typically used alongside the [`cms`](http://github.com/silverstripe/silverstripe-cms) module.
|
||||
|
@ -22,4 +22,4 @@
|
||||
"autoload": {
|
||||
"classmap": ["tests/behat/features/bootstrap"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ abstract class SS_Database {
|
||||
* Returns true if the given table exists in the database
|
||||
*/
|
||||
abstract public function hasTable($tableName);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the enum values available on the given field
|
||||
*/
|
||||
@ -180,12 +180,12 @@ abstract class SS_Database {
|
||||
* @var array
|
||||
*/
|
||||
protected $indexList;
|
||||
|
||||
|
||||
/**
|
||||
* Keeps track whether we are currently updating the schema.
|
||||
*/
|
||||
protected $schemaIsUpdating = false;
|
||||
|
||||
|
||||
/**
|
||||
* Large array structure that represents a schema update transaction
|
||||
*/
|
||||
@ -213,16 +213,16 @@ abstract class SS_Database {
|
||||
public function endSchemaUpdate() {
|
||||
foreach($this->schemaUpdateTransaction as $tableName => $changes) {
|
||||
switch($changes['command']) {
|
||||
case 'create':
|
||||
case 'create':
|
||||
$this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'],
|
||||
@$changes['advancedOptions']);
|
||||
break;
|
||||
|
||||
case 'alter':
|
||||
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
||||
break;
|
||||
|
||||
case 'alter':
|
||||
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
||||
$changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'],
|
||||
@$changes['advancedOptions']);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->schemaUpdateTransaction = null;
|
||||
@ -445,7 +445,7 @@ abstract class SS_Database {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($newTable || !isset($this->indexList[$table][$index_alt])) {
|
||||
$this->transCreateIndex($table, $index, $spec);
|
||||
$this->alterationMessage("Index $table.$index: created as "
|
||||
@ -669,7 +669,7 @@ abstract class SS_Database {
|
||||
*/
|
||||
public static function replace_with_null(&$array) {
|
||||
$array = preg_replace('/= *\'\'/', '= null', $array);
|
||||
|
||||
|
||||
if(is_array($array)) {
|
||||
foreach($array as $key => $value) {
|
||||
if(is_array($value)) {
|
||||
@ -701,7 +701,7 @@ abstract class SS_Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a message about database alteration
|
||||
* Show a message about database alteration
|
||||
*
|
||||
* @param string message to display
|
||||
* @param string type one of [created|changed|repaired|obsolete|deleted|error]
|
||||
@ -740,7 +740,7 @@ abstract class SS_Database {
|
||||
break;
|
||||
case "deleted":
|
||||
$color = "red";
|
||||
break;
|
||||
break;
|
||||
case "changed":
|
||||
$color = "blue";
|
||||
break;
|
||||
@ -828,8 +828,8 @@ abstract class SS_Database {
|
||||
public function sqlLimitToString($limit) {
|
||||
$clause = '';
|
||||
|
||||
// Pass limit as array or SQL string value
|
||||
if(is_array($limit)) {
|
||||
// Pass limit as array or SQL string value
|
||||
if(is_array($limit)) {
|
||||
if(!array_key_exists('limit', $limit)) {
|
||||
throw new InvalidArgumentException('Database::sqlLimitToString(): Wrong format for $limit: '
|
||||
. var_export($limit, true));
|
||||
@ -839,11 +839,11 @@ abstract class SS_Database {
|
||||
&& is_numeric($limit['limit'])) {
|
||||
|
||||
$combinedLimit = $limit['start'] ? "$limit[limit] OFFSET $limit[start]" : "$limit[limit]";
|
||||
} elseif(isset($limit['limit']) && is_numeric($limit['limit'])) {
|
||||
$combinedLimit = (int) $limit['limit'];
|
||||
} else {
|
||||
$combinedLimit = false;
|
||||
}
|
||||
} elseif(isset($limit['limit']) && is_numeric($limit['limit'])) {
|
||||
$combinedLimit = (int)$limit['limit'];
|
||||
} else {
|
||||
$combinedLimit = false;
|
||||
}
|
||||
if(!empty($combinedLimit)) $clause .= ' LIMIT ' . $combinedLimit;
|
||||
} else {
|
||||
$clause .= ' LIMIT ' . $limit;
|
||||
@ -859,9 +859,9 @@ abstract class SS_Database {
|
||||
public function sqlQueryToString(SQLQuery $query) {
|
||||
if($query->getDelete()) {
|
||||
$text = 'DELETE ';
|
||||
} else {
|
||||
} else {
|
||||
$text = $this->sqlSelectToString($query->getSelect(), $query->getDistinct());
|
||||
}
|
||||
}
|
||||
|
||||
if($query->getFrom()) $text .= $this->sqlFromToString($query->getFrom());
|
||||
if($query->getWhere()) $text .= $this->sqlWhereToString($query->getWhere(), $query->getConnective());
|
||||
@ -873,10 +873,10 @@ abstract class SS_Database {
|
||||
if($query->getOrderBy()) $text .= $this->sqlOrderByToString($query->getOrderBy());
|
||||
if($query->getLimit()) $text .= $this->sqlLimitToString($query->getLimit());
|
||||
}
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrap a string into DB-specific quotes. MySQL, PostgreSQL and SQLite3 only need single quotes around the string.
|
||||
* MSSQL will overload this and include it's own N prefix to mark the string as unicode, so characters like macrons
|
||||
@ -986,9 +986,9 @@ abstract class SS_Database {
|
||||
*/
|
||||
public function supportsLocks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the lock is available.
|
||||
* See {@link supportsLocks()} to check if locking is generally supported.
|
||||
*
|
||||
@ -1136,7 +1136,7 @@ abstract class SS_Query implements Iterator {
|
||||
$result .= "<tr>";
|
||||
foreach($record as $k => $v) {
|
||||
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
||||
}
|
||||
}
|
||||
$result .= "</tr> \n";
|
||||
}
|
||||
|
||||
@ -1213,7 +1213,7 @@ abstract class SS_Query implements Iterator {
|
||||
*/
|
||||
public function valid() {
|
||||
if(!$this->queryHasBegun) $this->next();
|
||||
return $this->currentRecord !== false;
|
||||
return $this->currentRecord !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user