MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
Driver.php
Ir para a documentação deste ficheiro.
1<?php
2/*
3 * $Id$
4 *
5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 *
17 * This software consists of voluntary contributions made by many individuals
18 * and is licensed under the LGPL. For more information, see
19 * <http://www.doctrine-project.org>.
20 */
21
23
30{
31 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
32 {
33 return new Connection(
34 $this->_constructPdoDsn($params),
35 $username,
36 $password,
37 $driverOptions
38 );
39 }
40
46 private function _constructPdoDsn(array $params)
47 {
48 $dsn = 'sqlsrv:server=';
49
50 if (isset($params['host'])) {
51 $dsn .= $params['host'];
52 }
53
54 if (isset($params['port']) && !empty($params['port'])) {
55 $dsn .= ',' . $params['port'];
56 }
57
58 if (isset($params['dbname'])) {
59 $dsn .= ';Database=' . $params['dbname'];
60 }
61
62 return $dsn;
63 }
64
65
66 public function getDatabasePlatform()
67 {
68 return new \Doctrine\DBAL\Platforms\MsSqlPlatform();
69 }
70
71 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
72 {
73 return new \Doctrine\DBAL\Schema\MsSqlSchemaManager($conn);
74 }
75
76 public function getName()
77 {
78 return 'pdo_sqlsrv';
79 }
80
81 public function getDatabase(\Doctrine\DBAL\Connection $conn)
82 {
83 $params = $conn->getParams();
84 return $params['dbname'];
85 }
86}
getDatabase(\Doctrine\DBAL\Connection $conn)
Definição Driver.php:81
connect(array $params, $username=null, $password=null, array $driverOptions=array())
Definição Driver.php:31
getSchemaManager(\Doctrine\DBAL\Connection $conn)
Definição Driver.php:71