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
|
## 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)).
|
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.
|
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": {
|
"autoload": {
|
||||||
"classmap": ["tests/behat/features/bootstrap"]
|
"classmap": ["tests/behat/features/bootstrap"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ abstract class SS_Database {
|
|||||||
* Returns true if the given table exists in the database
|
* Returns true if the given table exists in the database
|
||||||
*/
|
*/
|
||||||
abstract public function hasTable($tableName);
|
abstract public function hasTable($tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the enum values available on the given field
|
* Returns the enum values available on the given field
|
||||||
*/
|
*/
|
||||||
@ -180,12 +180,12 @@ abstract class SS_Database {
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $indexList;
|
protected $indexList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track whether we are currently updating the schema.
|
* Keeps track whether we are currently updating the schema.
|
||||||
*/
|
*/
|
||||||
protected $schemaIsUpdating = false;
|
protected $schemaIsUpdating = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Large array structure that represents a schema update transaction
|
* Large array structure that represents a schema update transaction
|
||||||
*/
|
*/
|
||||||
@ -213,16 +213,16 @@ abstract class SS_Database {
|
|||||||
public function endSchemaUpdate() {
|
public function endSchemaUpdate() {
|
||||||
foreach($this->schemaUpdateTransaction as $tableName => $changes) {
|
foreach($this->schemaUpdateTransaction as $tableName => $changes) {
|
||||||
switch($changes['command']) {
|
switch($changes['command']) {
|
||||||
case 'create':
|
case 'create':
|
||||||
$this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'],
|
$this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'],
|
||||||
@$changes['advancedOptions']);
|
@$changes['advancedOptions']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alter':
|
case 'alter':
|
||||||
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
||||||
$changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'],
|
$changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'],
|
||||||
@$changes['advancedOptions']);
|
@$changes['advancedOptions']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->schemaUpdateTransaction = null;
|
$this->schemaUpdateTransaction = null;
|
||||||
@ -445,7 +445,7 @@ abstract class SS_Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($newTable || !isset($this->indexList[$table][$index_alt])) {
|
if($newTable || !isset($this->indexList[$table][$index_alt])) {
|
||||||
$this->transCreateIndex($table, $index, $spec);
|
$this->transCreateIndex($table, $index, $spec);
|
||||||
$this->alterationMessage("Index $table.$index: created as "
|
$this->alterationMessage("Index $table.$index: created as "
|
||||||
@ -669,7 +669,7 @@ abstract class SS_Database {
|
|||||||
*/
|
*/
|
||||||
public static function replace_with_null(&$array) {
|
public static function replace_with_null(&$array) {
|
||||||
$array = preg_replace('/= *\'\'/', '= null', $array);
|
$array = preg_replace('/= *\'\'/', '= null', $array);
|
||||||
|
|
||||||
if(is_array($array)) {
|
if(is_array($array)) {
|
||||||
foreach($array as $key => $value) {
|
foreach($array as $key => $value) {
|
||||||
if(is_array($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 message to display
|
||||||
* @param string type one of [created|changed|repaired|obsolete|deleted|error]
|
* @param string type one of [created|changed|repaired|obsolete|deleted|error]
|
||||||
@ -740,7 +740,7 @@ abstract class SS_Database {
|
|||||||
break;
|
break;
|
||||||
case "deleted":
|
case "deleted":
|
||||||
$color = "red";
|
$color = "red";
|
||||||
break;
|
break;
|
||||||
case "changed":
|
case "changed":
|
||||||
$color = "blue";
|
$color = "blue";
|
||||||
break;
|
break;
|
||||||
@ -828,8 +828,8 @@ abstract class SS_Database {
|
|||||||
public function sqlLimitToString($limit) {
|
public function sqlLimitToString($limit) {
|
||||||
$clause = '';
|
$clause = '';
|
||||||
|
|
||||||
// Pass limit as array or SQL string value
|
// Pass limit as array or SQL string value
|
||||||
if(is_array($limit)) {
|
if(is_array($limit)) {
|
||||||
if(!array_key_exists('limit', $limit)) {
|
if(!array_key_exists('limit', $limit)) {
|
||||||
throw new InvalidArgumentException('Database::sqlLimitToString(): Wrong format for $limit: '
|
throw new InvalidArgumentException('Database::sqlLimitToString(): Wrong format for $limit: '
|
||||||
. var_export($limit, true));
|
. var_export($limit, true));
|
||||||
@ -839,11 +839,11 @@ abstract class SS_Database {
|
|||||||
&& is_numeric($limit['limit'])) {
|
&& is_numeric($limit['limit'])) {
|
||||||
|
|
||||||
$combinedLimit = $limit['start'] ? "$limit[limit] OFFSET $limit[start]" : "$limit[limit]";
|
$combinedLimit = $limit['start'] ? "$limit[limit] OFFSET $limit[start]" : "$limit[limit]";
|
||||||
} elseif(isset($limit['limit']) && is_numeric($limit['limit'])) {
|
} elseif(isset($limit['limit']) && is_numeric($limit['limit'])) {
|
||||||
$combinedLimit = (int) $limit['limit'];
|
$combinedLimit = (int)$limit['limit'];
|
||||||
} else {
|
} else {
|
||||||
$combinedLimit = false;
|
$combinedLimit = false;
|
||||||
}
|
}
|
||||||
if(!empty($combinedLimit)) $clause .= ' LIMIT ' . $combinedLimit;
|
if(!empty($combinedLimit)) $clause .= ' LIMIT ' . $combinedLimit;
|
||||||
} else {
|
} else {
|
||||||
$clause .= ' LIMIT ' . $limit;
|
$clause .= ' LIMIT ' . $limit;
|
||||||
@ -859,9 +859,9 @@ abstract class SS_Database {
|
|||||||
public function sqlQueryToString(SQLQuery $query) {
|
public function sqlQueryToString(SQLQuery $query) {
|
||||||
if($query->getDelete()) {
|
if($query->getDelete()) {
|
||||||
$text = 'DELETE ';
|
$text = 'DELETE ';
|
||||||
} else {
|
} else {
|
||||||
$text = $this->sqlSelectToString($query->getSelect(), $query->getDistinct());
|
$text = $this->sqlSelectToString($query->getSelect(), $query->getDistinct());
|
||||||
}
|
}
|
||||||
|
|
||||||
if($query->getFrom()) $text .= $this->sqlFromToString($query->getFrom());
|
if($query->getFrom()) $text .= $this->sqlFromToString($query->getFrom());
|
||||||
if($query->getWhere()) $text .= $this->sqlWhereToString($query->getWhere(), $query->getConnective());
|
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->getOrderBy()) $text .= $this->sqlOrderByToString($query->getOrderBy());
|
||||||
if($query->getLimit()) $text .= $this->sqlLimitToString($query->getLimit());
|
if($query->getLimit()) $text .= $this->sqlLimitToString($query->getLimit());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a string into DB-specific quotes. MySQL, PostgreSQL and SQLite3 only need single quotes around the string.
|
* 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
|
* 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() {
|
public function supportsLocks() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the lock is available.
|
* Returns if the lock is available.
|
||||||
* See {@link supportsLocks()} to check if locking is generally supported.
|
* See {@link supportsLocks()} to check if locking is generally supported.
|
||||||
*
|
*
|
||||||
@ -1136,7 +1136,7 @@ abstract class SS_Query implements Iterator {
|
|||||||
$result .= "<tr>";
|
$result .= "<tr>";
|
||||||
foreach($record as $k => $v) {
|
foreach($record as $k => $v) {
|
||||||
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
||||||
}
|
}
|
||||||
$result .= "</tr> \n";
|
$result .= "</tr> \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,7 +1213,7 @@ abstract class SS_Query implements Iterator {
|
|||||||
*/
|
*/
|
||||||
public function valid() {
|
public function valid() {
|
||||||
if(!$this->queryHasBegun) $this->next();
|
if(!$this->queryHasBegun) $this->next();
|
||||||
return $this->currentRecord !== false;
|
return $this->currentRecord !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user