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
489cb9eb
Unverified
Commit
489cb9eb
authored
Jan 13, 2020
by
Marco Pivetta
Committed by
GitHub
Jan 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3808 from morozov/remove-oci8-connection-execute-mode
Removed the OCI8Connection::getExecuteMode() method
parents
04db0efa
a0ff3648
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
26 deletions
+90
-26
UPGRADE.md
UPGRADE.md
+1
-0
ExecutionMode.php
lib/Doctrine/DBAL/Driver/OCI8/ExecutionMode.php
+31
-0
OCI8Connection.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
+9
-18
OCI8Statement.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+16
-8
ExecutionModeTest.php
tests/Doctrine/Tests/DBAL/Driver/OCI8/ExecutionModeTest.php
+33
-0
No files found.
UPGRADE.md
View file @
489cb9eb
...
...
@@ -63,6 +63,7 @@ Table columns are no longer indexed by column name. Use the `name` attribute of
-
Class
`Doctrine\DBAL\Driver\Mysqli\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\Mysqli\MysqliStatement`
was made final.
-
Class
`Doctrine\DBAL\Driver\OCI8\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\OCI8\OCI8Connection`
was made final.
-
Class
`Doctrine\DBAL\Driver\OCI8\OCI8Statement`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOSqlsrv\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOSqlsrv\Statement`
was made final.
...
...
lib/Doctrine/DBAL/Driver/OCI8/ExecutionMode.php
0 → 100644
View file @
489cb9eb
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Driver\OCI8
;
/**
* Encapsulates the execution mode that is shared between the connection and its statements.
*
* @internal This class is not covered by the backward compatibility promise
*/
final
class
ExecutionMode
{
/** @var bool */
private
$isAutoCommitEnabled
=
true
;
public
function
enableAutoCommit
()
:
void
{
$this
->
isAutoCommitEnabled
=
true
;
}
public
function
disableAutoCommit
()
:
void
{
$this
->
isAutoCommitEnabled
=
false
;
}
public
function
isAutoCommitEnabled
()
:
bool
{
return
$this
->
isAutoCommitEnabled
;
}
}
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
View file @
489cb9eb
...
...
@@ -9,9 +9,7 @@ use Doctrine\DBAL\Driver\ResultStatement;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
UnexpectedValueException
;
use
const
OCI_COMMIT_ON_SUCCESS
;
use
const
OCI_DEFAULT
;
use
const
OCI_NO_AUTO_COMMIT
;
use
function
addcslashes
;
use
function
oci_commit
;
use
function
oci_connect
;
...
...
@@ -26,13 +24,13 @@ use function str_replace;
/**
* OCI8 implementation of the Connection interface.
*/
class
OCI8Connection
implements
Connection
,
ServerInfoAwareConnection
final
class
OCI8Connection
implements
Connection
,
ServerInfoAwareConnection
{
/** @var resource */
protected
$dbh
;
/** @var
int
*/
pr
otected
$executeMode
=
OCI_COMMIT_ON_SUCCESS
;
/** @var
ExecutionMode
*/
pr
ivate
$executionMode
;
/**
* Creates a Connection to an Oracle Database using oci8 extension.
...
...
@@ -55,7 +53,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
());
}
$this
->
dbh
=
$dbh
;
$this
->
dbh
=
$dbh
;
$this
->
executionMode
=
new
ExecutionMode
();
}
/**
...
...
@@ -90,7 +89,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
*/
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
OCI8Statement
(
$this
->
dbh
,
$sql
,
$this
);
return
new
OCI8Statement
(
$this
->
dbh
,
$sql
,
$this
->
executionMode
);
}
/**
...
...
@@ -143,20 +142,12 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
return
$result
;
}
/**
* Returns the current execution mode.
*/
public
function
getExecuteMode
()
:
int
{
return
$this
->
executeMode
;
}
/**
* {@inheritdoc}
*/
public
function
beginTransaction
()
:
void
{
$this
->
execut
eMode
=
OCI_NO_AUTO_COMMIT
;
$this
->
execut
ionMode
->
disableAutoCommit
()
;
}
/**
...
...
@@ -168,7 +159,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
(
$this
->
dbh
));
}
$this
->
execut
eMode
=
OCI_COMMIT_ON_SUCCESS
;
$this
->
execut
ionMode
->
enableAutoCommit
()
;
}
/**
...
...
@@ -180,6 +171,6 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
(
$this
->
dbh
));
}
$this
->
execut
eMode
=
OCI_COMMIT_ON_SUCCESS
;
$this
->
execut
ionMode
->
enableAutoCommit
()
;
}
}
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
View file @
489cb9eb
...
...
@@ -15,9 +15,11 @@ use const OCI_ASSOC;
use
const
OCI_B_BIN
;
use
const
OCI_B_BLOB
;
use
const
OCI_BOTH
;
use
const
OCI_COMMIT_ON_SUCCESS
;
use
const
OCI_D_LOB
;
use
const
OCI_FETCHSTATEMENT_BY_COLUMN
;
use
const
OCI_FETCHSTATEMENT_BY_ROW
;
use
const
OCI_NO_AUTO_COMMIT
;
use
const
OCI_NUM
;
use
const
OCI_RETURN_LOBS
;
use
const
OCI_RETURN_NULLS
;
...
...
@@ -52,8 +54,8 @@ final class OCI8Statement implements IteratorAggregate, Statement
/** @var resource */
protected
$_sth
;
/** @var
OCI8Connection
*/
protected
$
_conn
;
/** @var
ExecutionMode
*/
protected
$
executionMode
;
/** @var int[] */
protected
static
$fetchModeMap
=
[
...
...
@@ -93,17 +95,17 @@ final class OCI8Statement implements IteratorAggregate, Statement
*
* @throws OCI8Exception
*/
public
function
__construct
(
$dbh
,
string
$query
,
OCI8Connection
$conn
)
public
function
__construct
(
$dbh
,
string
$query
,
ExecutionMode
$executionMode
)
{
[
$query
,
$paramMap
]
=
(
new
ConvertPositionalToNamedPlaceholders
())(
$query
);
$stmt
=
oci_parse
(
$dbh
,
$query
);
assert
(
is_resource
(
$stmt
));
$this
->
_sth
=
$stmt
;
$this
->
_dbh
=
$dbh
;
$this
->
_paramMap
=
$paramMap
;
$this
->
_conn
=
$conn
;
$this
->
_sth
=
$stmt
;
$this
->
_dbh
=
$dbh
;
$this
->
_paramMap
=
$paramMap
;
$this
->
executionMode
=
$executionMode
;
}
/**
...
...
@@ -208,7 +210,13 @@ final class OCI8Statement implements IteratorAggregate, Statement
}
}
$ret
=
@
oci_execute
(
$this
->
_sth
,
$this
->
_conn
->
getExecuteMode
());
if
(
$this
->
executionMode
->
isAutoCommitEnabled
())
{
$mode
=
OCI_COMMIT_ON_SUCCESS
;
}
else
{
$mode
=
OCI_NO_AUTO_COMMIT
;
}
$ret
=
@
oci_execute
(
$this
->
_sth
,
$mode
);
if
(
!
$ret
)
{
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
(
$this
->
_sth
));
}
...
...
tests/Doctrine/Tests/DBAL/Driver/OCI8/ExecutionModeTest.php
0 → 100644
View file @
489cb9eb
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Driver\OCI8
;
use
Doctrine\DBAL\Driver\OCI8\ExecutionMode
;
use
PHPStan\Testing\TestCase
;
final
class
ExecutionModeTest
extends
TestCase
{
/** @var ExecutionMode */
private
$mode
;
protected
function
setUp
()
:
void
{
$this
->
mode
=
new
ExecutionMode
();
}
public
function
testDefaultAutoCommitStatus
()
:
void
{
self
::
assertTrue
(
$this
->
mode
->
isAutoCommitEnabled
());
}
public
function
testChangeAutoCommitStatus
()
:
void
{
$this
->
mode
->
disableAutoCommit
();
self
::
assertFalse
(
$this
->
mode
->
isAutoCommitEnabled
());
$this
->
mode
->
enableAutoCommit
();
self
::
assertTrue
(
$this
->
mode
->
isAutoCommitEnabled
());
}
}
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