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
cb7fbee1
Commit
cb7fbee1
authored
Jan 31, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-295 - Add OracleSessionInit postConnect Subscriber
parent
e7f5089e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
0 deletions
+119
-0
OracleSessionInit.php
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
+82
-0
AllTests.php
tests/Doctrine/Tests/DBAL/AllTests.php
+3
-0
OracleSessionInitTest.php
tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
+33
-0
dbproperties.xml.dev
tests/dbproperties.xml.dev
+1
-0
No files found.
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
0 → 100644
View file @
cb7fbee1
<?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.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Event\Listeners
;
use
Doctrine\DBAL\Event\ConnectionEventArgs
;
use
Doctrine\DBAL\Events
;
use
Doctrine\Common\EventSubscriber
;
/**
* Should be used when Oracle Server default enviroment does not match the Doctrine requirements.
*
* The following enviroment variables are required for the Doctrine default date format:
*
* NLS_TIME_FORMAT="HH24:MI:SS"
* NLS_DATE_FORMAT="YYYY-MM-DD"
* NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS"
* NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS TZH:TZM"
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class
OracleSessionInit
implements
EventSubscriber
{
protected
$_defaultSessionVars
=
array
(
'NLS_TIME_FORMAT'
=>
"HH24:MI:SS"
,
'NLS_DATE_FORMAT'
=>
"YYYY-MM-DD"
,
'NLS_TIMESTAMP_FORMAT'
=>
"YYYY-MM-DD HH24:MI:SS"
,
'NLS_TIMESTAMP_TZ_FORMAT'
=>
"YYYY-MM-DD HH24:MI:SS TZH:TZM"
,
);
/**
* @param array $oracleSessionVars
*/
public
function
__construct
(
array
$oracleSessionVars
=
array
())
{
$this
->
_defaultSessionVars
=
array_merge
(
$this
->
_defaultSessionVars
,
$oracleSessionVars
);
}
/**
* @param ConnectionEventArgs $args
* @return void
*/
public
function
postConnect
(
ConnectionEventArgs
$args
)
{
if
(
count
(
$this
->
_defaultSessionVars
))
{
array_change_key_case
(
$this
->
_defaultSessionVars
,
\CASE_UPPER
);
$vars
=
array
();
foreach
(
$this
->
_defaultSessionVars
AS
$option
=>
$value
)
{
$vars
[]
=
$option
.
" = '"
.
$value
.
"'"
;
}
$sql
=
"ALTER SESSION SET "
.
implode
(
" "
,
$vars
);
$args
->
getConnection
()
->
executeUpdate
(
$sql
);
}
}
public
function
getSubscribedEvents
()
{
return
array
(
Events
::
postConnect
);
}
}
tests/Doctrine/Tests/DBAL/AllTests.php
View file @
cb7fbee1
...
...
@@ -56,6 +56,9 @@ class AllTests
// Connection test
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\ConnectionTest'
);
// Events and Listeners
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Events\OracleSessionInitTest'
);
// All Functional DBAL tests
$suite
->
addTest
(
Functional\AllTests
::
suite
());
...
...
tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
0 → 100644
View file @
cb7fbee1
<?php
namespace
Doctrine\Tests\DBAL\Events
;
use
Doctrine\Tests\DbalTestCase
;
use
Doctrine\DBAL\Event\Listeners\OracleSessionInit
;
use
Doctrine\DBAL\Event\ConnectionEventArgs
;
use
Doctrine\DBAL\Events
;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
OracleSessionInitTest
extends
DbalTestCase
{
public
function
testPostConnect
()
{
$connectionMock
=
$this
->
getMock
(
'Doctrine\DBAL\Connection'
,
array
(),
array
(),
''
,
false
);
$connectionMock
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
->
with
(
$this
->
isType
(
'string'
));
$eventArgs
=
new
ConnectionEventArgs
(
$connectionMock
);
$listener
=
new
OracleSessionInit
();
$listener
->
postConnect
(
$eventArgs
);
}
public
function
testGetSubscribedEvents
()
{
$listener
=
new
OracleSessionInit
();
$this
->
assertEquals
(
array
(
Events
::
postConnect
),
$listener
->
getSubscribedEvents
());
}
}
\ No newline at end of file
tests/dbproperties.xml.dev
View file @
cb7fbee1
...
...
@@ -20,6 +20,7 @@
<var
name=
"db_password"
value=
""
/>
<var
name=
"db_name"
value=
"doctrine_tests"
/>
<var
name=
"db_port"
value=
"3306"
/>
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->
<!-- Database for temporary connections (i.e. to drop/create the main database) -->
<var
name=
"tmpdb_type"
value=
"pdo_mysql"
/>
...
...
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