Skip to content

Commit

Permalink
Merge pull request doctrine#16 from doctrine/master
Browse files Browse the repository at this point in the history
Head merged back
  • Loading branch information
ancpru committed Oct 17, 2015
2 parents b8fca54 + 2c789aa commit 1f1e9bd
Show file tree
Hide file tree
Showing 72 changed files with 1,534 additions and 302 deletions.
64 changes: 63 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
Expand Down Expand Up @@ -29,6 +28,69 @@ before_script:
script: ./vendor/bin/phpunit --configuration tests/travis/$DB.travis.xml

matrix:
include:
- php: 5.4
env: DB=mariadb
addons:
mariadb: 5.5
- php: 5.5
env: DB=mariadb
addons:
mariadb: 5.5
- php: 5.6
env: DB=mariadb
addons:
mariadb: 5.5
- php: 7.0
env: DB=mariadb
addons:
mariadb: 5.5
- php: hhvm
env: DB=mariadb
addons:
mariadb: 5.5

- php: 5.4
env: DB=mariadb
addons:
mariadb: 10.0
- php: 5.5
env: DB=mariadb
addons:
mariadb: 10.0
- php: 5.6
env: DB=mariadb
addons:
mariadb: 10.0
- php: 7.0
env: DB=mariadb
addons:
mariadb: 10.0
- php: hhvm
env: DB=mariadb
addons:
mariadb: 10.0

- php: 5.4
env: DB=mariadb
addons:
mariadb: 10.1
- php: 5.5
env: DB=mariadb
addons:
mariadb: 10.1
- php: 5.6
env: DB=mariadb
addons:
mariadb: 10.1
- php: 7.0
env: DB=mariadb
addons:
mariadb: 10.1
- php: hhvm
env: DB=mariadb
addons:
mariadb: 10.1
allow_failures:
- php: 7.0
- php: hhvm
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Powerful database abstraction layer with many features for database schema intro
* [Website](http://www.doctrine-project.org/projects/dbal.html)
* [Documentation](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/)
* [Issue Tracker](http://www.doctrine-project.org/jira/browse/DBAL)
* [Downloads](http://github.com/doctrine/dbal/downloads)


[Master image]: https://img.shields.io/travis/doctrine/dbal/master.svg?style=flat-square
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
],
"require": {
"php": ">=5.3.2",
"doctrine/common": ">=2.4,<2.6-dev"
"php": ">=5.4",
"doctrine/common": "~2.4"
},
"require-dev": {
"phpunit/phpunit": "4.*",
Expand Down
14 changes: 12 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Doctrine DBAL Documentation

## How to Generate
## How to Generate:
Using Ubuntu 14.04 LTS:

1. Run ./bin/install-dependencies.sh
2. Run ./bin/generate-docs.sh

It will generate the documentation into the build directory of the checkout.
It will generate the documentation into the build directory of the checkout.


## Theme issues

If you get a "Theme error", check if the `en/_theme` subdirectory is empty,
in which case you will need to run:

1. git submodule init
2. git submodule update
4 changes: 1 addition & 3 deletions docs/bin/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/bash
sudo apt-get install python25 python25-dev texlive-full rubber
sudo easy_install pygments
sudo easy_install sphinx
sudo apt-get update && sudo apt-get install -y python2.7 python-sphinx python-pygments
6 changes: 3 additions & 3 deletions docs/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@

# General information about the project.
project = u'Doctrine DBAL'
copyright = u'2010, Roman Borschel, Guilherme Blanco, Benjamin Eberlei, Jonathan Wage'
copyright = u'2010-2015, Roman Borschel, Guilherme Blanco, Benjamin Eberlei, Jonathan Wage'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.1'
version = '2'
# The full version, including alpha/beta/rc tags.
release = '2.1.0'
release = '2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/data-retrieval-and-manipulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ returns the affected rows count:
The ``$types`` variable contains the PDO or Doctrine Type constants
to perform necessary type conversions between actual input
parameters and expected database values. See the
`Types <./types#type-conversion>`_ section for more information.
`Types <./types#mapping-matrix>`_ section for more information.

executeQuery()
~~~~~~~~~~~~~~
Expand All @@ -351,7 +351,7 @@ parameters to the execute method, then returning the statement:
The ``$types`` variable contains the PDO or Doctrine Type constants
to perform necessary type conversions between actual input
parameters and expected database values. See the
`Types <./types#type-conversion>`_ section for more information.
`Types <./types#mapping-matrix>`_ section for more information.

fetchAll()
~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/schema-representation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ The following options are completely vendor specific and absolutely not portable

- **charset** (string): The character set to use for the column. Currently only supported
on MySQL and Drizzle.
- **collate** (string): The collation to use for the column. Currently only supported on
SQL Server.
- **collation** (string): The collation to use for the column. Supported by MySQL, PostgreSQL,
Sqlite, SQL Server and Drizzle.
- **check** (string): The check constraint clause to add to the column.
Defaults to ``null``.
19 changes: 1 addition & 18 deletions docs/en/reference/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,4 @@ the ``Connection#quote`` method:
$sql = "SELECT * FROM users WHERE name = " . $connection->quote($_GET['username'], \PDO::PARAM_STR);
This method is only available for SQL, not for DQL. For DQL it is always encouraged to use prepared
statements not only for security, but also for caching reasons.

Non-ASCII compatible Charsets in MySQL
--------------------------------------

Up until PHP 5.3.6 PDO has a security problem when using non ascii compatible charsets. Even if specifying
the charset using "SET NAMES", emulated prepared statements and ``PDO#quote`` could not reliably escape
values, opening up to potential SQL injections. If you are running PHP 5.3.6 you can solve this issue
by passing the driver option "charset" to Doctrine PDO MySQL driver. Using SET NAMES does not suffice!

.. code-block::
<?php
$conn = DriverManager::getConnection(array(
'driver' => 'pdo_mysql',
'charset' => 'UTF8',
));
statements not only for security, but also for caching reasons.
2 changes: 1 addition & 1 deletion docs/en/reference/transactions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ to avoid nesting transaction blocks. If this is not possible
because the nested transaction blocks are in a third-party API
you're out of luck.

All that is guaruanteed to the inner transaction is that it still
All that is guaranteed to the inner transaction is that it still
happens atomically, all or nothing, the transaction just gets a
wider scope and the control is handed to the outer scope.

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ public function connect()
}

$driverOptions = isset($this->_params['driverOptions']) ?
$this->_params['driverOptions'] : array();
$this->_params['driverOptions'] : array();
$user = isset($this->_params['user']) ? $this->_params['user'] : null;
$password = isset($this->_params['password']) ?
$this->_params['password'] : null;
$this->_params['password'] : null;

$this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions);
$this->_isConnected = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/AbstractDriverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep
* Constructor.
*
* @param string $message The driver error message.
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occured, if any.
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
* @param integer|string|null $errorCode The driver specific error code if any.
*/
public function __construct($message, $sqlState = null, $errorCode = null)
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'];
if (isset($params['dbname'])) {
return $params['dbname'];
}

return $conn->query('SELECT DB_NAME()')->fetchColumn();
}

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();

return $params['dbname'];
if (isset($params['dbname'])) {
return $params['dbname'];
}

return $conn->query('SELECT DB_NAME()')->fetchColumn();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/
public function __construct(array $params, $username, $password, $driverOptions = array())
{
$isPersistant = (isset($params['persistent']) && $params['persistent'] == true);
$isPersistent = (isset($params['persistent']) && $params['persistent'] == true);

if ($isPersistant) {
if ($isPersistent) {
$this->_conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
} else {
$this->_conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ public function getDropTemporaryTableSQL($table)
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
} elseif (!is_string($table)) {
throw new \InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
throw new \InvalidArgumentException('getDropTemporaryTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}

return 'DROP TEMPORARY TABLE ' . $table;
Expand Down
8 changes: 8 additions & 0 deletions lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ protected function initializeDoctrineTypeMappings()
parent::initializeDoctrineTypeMappings();
$this->doctrineTypeMapping['json'] = 'json_array';
}

/**
* {@inheritdoc}
*/
public function getCloseActiveDatabaseConnectionsSQL($database)
{
return "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$database'";
}
}
28 changes: 28 additions & 0 deletions lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,34 @@ public function getCreateDatabaseSQL($name)
return 'CREATE DATABASE ' . $name;
}

/**
* Returns the SQL statement for disallowing new connections on the given database.
*
* This is useful to force DROP DATABASE operations which could fail because of active connections.
*
* @param string $database The name of the database to disallow new connections for.
*
* @return string
*/
public function getDisallowDatabaseConnectionsSQL($database)
{
return "UPDATE pg_database SET datallowconn = 'false' WHERE datname = '$database'";
}

/**
* Returns the SQL statement for closing currently active connections on the given database.
*
* This is useful to force DROP DATABASE operations which could fail because of active connections.
*
* @param string $database The name of the database to close currently active connections for.
*
* @return string
*/
public function getCloseActiveDatabaseConnectionsSQL($database)
{
return "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = '$database'";
}

/**
* {@inheritDoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SqlitePlatform extends AbstractPlatform
*/
public function getRegexpExpression()
{
return 'RLIKE';
return 'REGEXP';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function listSequences($database = null)
*
* In contrast to other libraries and to the old version of Doctrine,
* this column definition does try to contain the 'primary' field for
* the reason that it is not portable accross different RDBMS. Use
* the reason that it is not portable across different RDBMS. Use
* {@see listTableIndexes($tableName)} to retrieve the primary key
* of a table. We're a RDBMS specifies more details these are held
* in the platformDetails array.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;

/**
* Marker interface for contraints.
* Marker interface for constraints.
*
* @link www.doctrine-project.org
* @since 2.0
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function isFullfilledBy(Index $other)
}

if ( ! $this->isUnique() && ! $this->isPrimary()) {
// this is a special case: If the current key is neither primary or unique, any uniqe or
// this is a special case: If the current key is neither primary or unique, any unique or
// primary key will always have the same effect for the index and there cannot be any constraint
// overlaps. This means a primary or unique index can always fulfill the requirements of just an
// index that has no constraints.
Expand Down
Loading

0 comments on commit 1f1e9bd

Please sign in to comment.