Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
79034ea7
Commit
79034ea7
authored
Oct 26, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Mysql, Mssql and Firebird expression drivers, fixes #199, #200, #201
Ticket: 199
parent
0d75147c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
234 additions
and
2 deletions
+234
-2
Connection.php
lib/Doctrine/Connection.php
+18
-1
Mysql.php
lib/Doctrine/Connection/Mysql.php
+9
-0
Export.php
lib/Doctrine/Export.php
+66
-1
Firebird.php
lib/Doctrine/Expression/Firebird.php
+39
-0
Mssql.php
lib/Doctrine/Expression/Mssql.php
+73
-0
Mysql.php
lib/Doctrine/Expression/Mysql.php
+29
-0
No files found.
lib/Doctrine/Connection.php
View file @
79034ea7
...
...
@@ -67,6 +67,15 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onOpen
(
$this
);
}
/**
* quoteIdentifier
*
* @param string $identifier identifier to be quoted
* @return string modified identifier
*/
public
function
quoteIdentifier
(
$identifier
)
{
return
$identifier
;
}
/**
* getUnitOfWork
*
...
...
@@ -145,7 +154,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
*
@throws Doctrine_Connection_Mysql_Exception if using unknown isolation level
*
* @throws PDOException if something fails at the PDO level
* @return void
*/
...
...
@@ -162,6 +171,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public
function
getRegexpOperator
()
{
throw
new
Doctrine_Connection_Exception
(
'Regular expression operator is not supported by this database driver.'
);
}
/**
* getTransactionIsolation
*
* @return string returns the current session transaction isolation level
*/
public
function
getTransactionIsolation
()
{
throw
new
Doctrine_Connection_Exception
(
'Fetching transaction isolation level not supported by this database driver.'
);
}
/**
* query
* queries the database with Doctrine Query Language
...
...
lib/Doctrine/Connection/Mysql.php
View file @
79034ea7
...
...
@@ -46,6 +46,15 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
public
function
getRegexpOperator
()
{
return
'RLIKE'
;
}
/**
* getTransactionIsolation
*
* @return string returns the current session transaction isolation level
*/
public
function
getTransactionIsolation
()
{
$ret
=
$this
->
dbh
->
query
(
'SELECT @@tx_isolation'
)
->
fetch
(
PDO
::
FETCH_NUM
);
return
$ret
[
0
];
}
/**
* Set the transacton isolation level.
*
...
...
lib/Doctrine/Export.php
View file @
79034ea7
...
...
@@ -27,14 +27,79 @@
* @license LGPL
*/
class
Doctrine_Export
{
/**
* @var Doctrine_Connection $conn Doctrine_Connection object
*/
private
$conn
;
/**
* @var mixed $dbh the database handler (either PDO or Doctrine_DB object)
*/
private
$dbh
;
public
function
__construct
(
$conn
)
{
$this
->
conn
=
$conn
;
$this
->
dbh
=
$conn
->
getDBH
();
}
/**
* dropTable
*
* @param string $table name of table that should be dropped from the database
* @throws PDOException
* @return void
*/
public
function
dropTable
(
$table
)
{
$this
->
dbh
->
query
(
'DROP TABLE '
.
$table
);
}
/**
* [[ borrowed from PEAR MDB2 ]]
*
* Get the stucture of a field into an array
*
*
* @param string $table name of the table on which the index is to be created
* @param string $name name of the index to be created
* @param array $definition associative array that defines properties of the index to be created.
* Currently, only one property named FIELDS is supported. This property
* is also an associative with the names of the index fields as array
* indexes. Each entry of this array is set to another type of associative
* array that specifies properties of the index that are specific to
* each field.
*
* Currently, only the sorting property is supported. It should be used
* to define the sorting direction of the index. It may be set to either
* ascending or descending.
*
* Not all DBMS support index sorting direction configuration. The DBMS
* drivers of those that do not support it ignore this property. Use the
* function supports() to determine whether the DBMS driver can manage indexes.
*
* Example
* array(
* 'fields' => array(
* 'user_name' => array(
* 'sorting' => 'ascending'
* ),
* 'last_login' => array()
* )
* )
* @throws PDOException
* @return void
*/
function
createIndex
(
$table
,
$name
,
array
$definition
)
{
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
);
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
);
$query
=
"CREATE INDEX
$name
ON
$table
"
;
$fields
=
array
();
foreach
(
array_keys
(
$definition
[
'fields'
])
as
$field
)
{
$fields
[]
=
$this
->
conn
->
quoteIdentifier
(
$field
);
}
$query
.=
' ('
.
implode
(
', '
,
$fields
)
.
')'
;
return
$this
->
dbh
->
query
(
$query
);
}
/**
* export
*/
public
function
export
()
{
$parent
=
new
ReflectionClass
(
'Doctrine_Record'
);
$conn
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
();
...
...
lib/Doctrine/Expression/Firebird.php
0 → 100644
View file @
79034ea7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Expression'
);
/**
* Doctrine_Expression_Firebird
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Expression_Firebird
extends
Doctrine_Expression
{
/**
* return string for internal table used when calling only a function
*
* @return string for internal table used when calling only a function
* @access public
*/
public
function
functionTable
()
{
return
' FROM RDB$DATABASE'
;
}
}
lib/Doctrine/Expression/Mssql.php
0 → 100644
View file @
79034ea7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Expression'
);
/**
* Doctrine_Expression_Mssql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Expression_Mssql
extends
Doctrine_Expression
{
/**
* Return string to call a variable with the current timestamp inside an SQL statement
* There are three special variables for current date and time:
* - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
* - CURRENT_DATE (date, DATE type)
* - CURRENT_TIME (time, TIME type)
*
* @return string to call a variable with the current timestamp
* @access public
*/
public
function
now
(
$type
=
'timestamp'
)
{
switch
(
$type
)
{
case
'time'
:
case
'date'
:
case
'timestamp'
:
default
:
return
'GETDATE()'
;
}
}
/**
* return string to call a function to get a substring inside an SQL statement
*
* @return string to call a function to get a substring
*/
public
function
substring
(
$value
,
$position
=
1
,
$length
=
null
)
{
if
(
!
is_null
(
$length
))
return
"SUBSTRING(
$value
,
$position
,
$length
)"
;
return
"SUBSTRING(
$value
,
$position
, LEN(
$value
) -
$position
+ 1)"
;
}
/**
* Returns string to concatenate two or more string parameters
*
* @param string $arg1
* @param string $arg2
* @param string $values...
* @return string to concatenate two strings
* @access public
**/
function
concat
(
$arg1
,
$arg2
)
{
$args
=
func_get_args
();
return
'('
.
implode
(
' + '
,
$args
)
.
')'
;
}
}
lib/Doctrine/Expression/Mysql.php
0 → 100644
View file @
79034ea7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Expression'
);
/**
* Doctrine_Expression_Mysql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Expression_Mysql
extends
Doctrine_Expression
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment