MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
Driver.php
Ir para a documentação deste ficheiro.
1<?php
2/*
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the LGPL. For more information, see
17 * <http://www.doctrine-project.org>.
18 */
19
21
28{
32 protected $_userDefinedFunctions = array(
33 'sqrt' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'), 'numArgs' => 1),
34 'mod' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'), 'numArgs' => 2),
35 'locate' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'), 'numArgs' => -1),
36 );
37
47 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
48 {
49 if (isset($driverOptions['userDefinedFunctions'])) {
50 $this->_userDefinedFunctions = array_merge(
51 $this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']);
52 unset($driverOptions['userDefinedFunctions']);
53 }
54
55 $pdo = new \Doctrine\DBAL\Driver\PDOConnection(
56 $this->_constructPdoDsn($params),
57 $username,
58 $password,
59 $driverOptions
60 );
61
62 foreach ($this->_userDefinedFunctions AS $fn => $data) {
63 $pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']);
64 }
65
66 return $pdo;
67 }
68
75 protected function _constructPdoDsn(array $params)
76 {
77 $dsn = 'sqlite:';
78 if (isset($params['path'])) {
79 $dsn .= $params['path'];
80 } else if (isset($params['memory'])) {
81 $dsn .= ':memory:';
82 }
83
84 return $dsn;
85 }
86
90 public function getDatabasePlatform()
91 {
92 return new \Doctrine\DBAL\Platforms\SqlitePlatform();
93 }
94
101 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
102 {
103 return new \Doctrine\DBAL\Schema\SqliteSchemaManager($conn);
104 }
105
106 public function getName()
107 {
108 return 'pdo_sqlite';
109 }
110
111 public function getDatabase(\Doctrine\DBAL\Connection $conn)
112 {
113 $params = $conn->getParams();
114 return isset($params['path']) ? $params['path'] : null;
115 }
116}
getDatabase(\Doctrine\DBAL\Connection $conn)
Definição Driver.php:111
connect(array $params, $username=null, $password=null, array $driverOptions=array())
Definição Driver.php:47
getSchemaManager(\Doctrine\DBAL\Connection $conn)
Definição Driver.php:101