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
e2dd9536
Commit
e2dd9536
authored
Jun 09, 2010
by
Juozas Kaziukenas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed sqlsrv driver
parent
e8b60d76
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
505 deletions
+0
-505
Driver.php
lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php
+0
-80
SqlsrvConnection.php
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php
+0
-135
SqlsrvException.php
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvException.php
+0
-30
SqlsrvStatement.php
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
+0
-259
DriverManager.php
lib/Doctrine/DBAL/DriverManager.php
+0
-1
No files found.
lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php
deleted
100644 → 0
View file @
e8b60d76
<?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\Driver\Sqlsrv
;
use
Doctrine\DBAL\Platforms
;
/**
* A Doctrine DBAL driver for the Microsoft SQL Native Client PHP extension.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class
Driver
implements
\Doctrine\DBAL\Driver
{
public
function
connect
(
array
$params
,
$username
=
null
,
$password
=
null
,
array
$driverOptions
=
array
())
{
$serverName
=
''
;
// construct server name
$serverName
=
$params
[
'host'
];
if
(
isset
(
$params
[
'port'
])
&&
!
empty
(
$params
[
'port'
]))
{
$port
=
(
integer
)
$params
[
'port'
];
$serverName
.=
', '
.
$port
;
}
$connectionInfo
=
array
(
'Database'
=>
$params
[
'dbname'
],
'ReturnDatesAsStrings'
=>
true
,
);
if
(
isset
(
$username
)
&&
!
empty
(
$username
)
&&
isset
(
$password
)
&&
!
empty
(
$password
))
{
$connectionInfo
+=
array
(
'UID'
=>
$username
,
'PWD'
=>
$password
,
);
}
return
new
SqlsrvConnection
(
$serverName
,
$connectionInfo
);
}
public
function
getDatabasePlatform
()
{
return
new
\Doctrine\DBAL\Platforms\SqlsrvPlatform
();
}
public
function
getSchemaManager
(
\Doctrine\DBAL\Connection
$conn
)
{
return
new
\Doctrine\DBAL\Schema\SqlsrvSchemaManager
(
$conn
);
}
public
function
getName
()
{
return
'sqlsrv'
;
}
public
function
getDatabase
(
\Doctrine\DBAL\Connection
$conn
)
{
$params
=
$conn
->
getParams
();
return
$params
[
'dbname'
];
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php
deleted
100644 → 0
View file @
e8b60d76
<?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\Driver\Sqlsrv
;
/**
* Sqlsrv implementation of the Connection interface.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class
SqlsrvConnection
implements
\Doctrine\DBAL\Driver\Connection
{
private
$_dbh
;
public
function
__construct
(
$serverName
,
array
$connectionInfo
)
{
$this
->
_dbh
=
@
sqlsrv_connect
(
$serverName
,
$connectionInfo
);
if
(
!
is_resource
(
$this
->
_dbh
))
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
}
public
function
__destruct
()
{
sqlsrv_close
(
$this
->
_dbh
);
}
public
function
prepare
(
$prepareString
)
{
return
new
SqlsrvStatement
(
$this
->
_dbh
,
$prepareString
);
}
public
function
query
()
{
$args
=
func_get_args
();
$sql
=
$args
[
0
];
//$fetchMode = $args[1];
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
return
$stmt
;
}
public
function
quote
(
$input
,
$type
=
\PDO
::
PARAM_STR
)
{
return
is_numeric
(
$input
)
?
$input
:
"'"
.
str_replace
(
"'"
,
"''"
,
$input
)
.
"'"
;
}
public
function
exec
(
$statement
)
{
$stmt
=
$this
->
prepare
(
$statement
);
$stmt
->
execute
();
return
$stmt
->
rowCount
();
}
public
function
lastInsertId
(
$name
=
null
)
{
$id
=
$this
->
query
(
'SELECT @@IDENTITY'
)
->
fetchColumn
();
if
(
!
$id
)
{
return
1
;
}
return
$id
;
}
public
function
beginTransaction
()
{
if
(
!
sqlsrv_begin_transaction
(
$this
->
_dbh
))
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
return
true
;
}
public
function
commit
()
{
if
(
!
sqlsrv_commit
(
$this
->
_dbh
))
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
return
true
;
}
public
function
rollBack
()
{
if
(
!
sqlsrv_rollback
(
$this
->
_dbh
))
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
return
true
;
}
public
function
errorCode
()
{
$errors
=
sqlsrv_errors
();
if
(
false
===
isset
(
$errors
[
0
][
'code'
]))
{
return
null
;
}
$error
=
$errors
[
0
];
return
$error
[
'code'
];
}
public
function
errorInfo
()
{
$errors
=
sqlsrv_errors
();
if
(
false
===
isset
(
$errors
[
0
][
'message'
]))
{
return
null
;
}
return
$errors
[
0
];
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvException.php
deleted
100644 → 0
View file @
e8b60d76
<?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\Driver\Sqlsrv
;
class
SqlsrvException
extends
\Exception
{
static
public
function
fromErrorInfo
(
$error
)
{
return
new
self
(
$error
[
'message'
],
$error
[
'code'
]);
}
}
lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
deleted
100644 → 0
View file @
e8b60d76
<?php
/*
* $Id: Interface.php 3882 2008-02-22 18:11:35Z jwage $
*
* 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\Driver\Sqlsrv
;
use
\PDO
;
/**
* The Sql server implementation of the Statement interface.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class
SqlsrvStatement
implements
\Doctrine\DBAL\Driver\Statement
{
/** Statement handle. */
private
$_sth
;
private
$_dbh
=
null
;
private
$_query
=
null
;
private
static
$fetchStyleMap
=
array
(
PDO
::
FETCH_BOTH
=>
SQLSRV_FETCH_BOTH
,
PDO
::
FETCH_ASSOC
=>
SQLSRV_FETCH_ASSOC
,
PDO
::
FETCH_NUM
=>
SQLSRV_FETCH_NUMERIC
);
private
$_paramMap
=
array
();
private
$_bindParams
=
array
();
/**
* Creates a new SqlsrvStatement that uses the given connection handle and SQL statement.
*
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
*/
public
function
__construct
(
$dbh
,
$statement
)
{
$this
->
_dbh
=
$dbh
;
$this
->
_query
=
$this
->
_convertPositionalToNamedPlaceholders
(
$statement
);
}
/**
* Sqlsrv doesnt support bamed params and these should be replaced
* to question marks
*
* @param string $statement The SQL statement to convert.
*/
private
function
_convertPositionalToNamedPlaceholders
(
$statement
)
{
// reset bind params
$this
->
bindParams
=
array
();
// get params count
$param_count
=
substr_count
(
$statement
,
'?'
);
// prepare bind params
if
(
$param_count
>
0
)
{
for
(
$i
=
0
;
$i
<
$param_count
;
$i
++
)
{
// preapre bind param for later usage
$this
->
_bindParams
[
$i
]
=
null
;
}
}
else
{
// parse statement and get named bind params
if
(
preg_match_all
(
'/[= ]:([a-z]+)\b/'
,
$statement
,
$matches
))
{
for
(
$i
=
0
,
$c
=
count
(
$matches
[
1
]);
$i
<
$c
;
$i
++
)
{
// preapre bind param for later usage
$this
->
_bindParams
[
$i
]
=
null
;
// save name for later usage
$this
->
_paramMap
[
$matches
[
1
][
$i
]]
=
$i
+
1
;
// replace to question mark (:name => ?)
$statement
=
str_replace
(
':'
.
$matches
[
1
][
$i
],
'?'
,
$statement
);
}
}
}
return
$statement
;
}
/**
* {@inheritdoc}
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
null
)
{
return
$this
->
bindParam
(
$param
,
$value
,
$type
);
}
/**
* {@inheritdoc}
*/
public
function
bindParam
(
$column
,
&
$variable
,
$type
=
null
)
{
$column
=
isset
(
$this
->
_paramMap
[
$column
])
?
$this
->
_paramMap
[
$column
]
:
$column
;
if
(
$column
>
0
&&
$column
<=
count
(
$this
->
_bindParams
))
{
$this
->
_bindParams
[
$column
-
1
]
=
&
$variable
;
}
else
{
throw
SqlsrvException
::
fromErrorInfo
(
array
(
'message'
=>
"Parameter out of bounds"
));
}
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public
function
closeCursor
()
{
return
sqlsrv_free_stmt
(
$this
->
_sth
);
}
/**
* {@inheritdoc}
*/
public
function
columnCount
()
{
return
sqlsrv_num_fields
(
$this
->
_sth
);
}
/**
* {@inheritdoc}
*/
public
function
errorCode
()
{
$errors
=
sqlsrv_errors
();
if
(
false
===
isset
(
$errors
[
0
][
'code'
]))
{
return
null
;
}
$error
=
$errors
[
0
];
return
$error
[
'code'
];
}
/**
* {@inheritdoc}
*/
public
function
errorInfo
()
{
$errors
=
sqlsrv_errors
();
if
(
false
===
isset
(
$errors
[
0
][
'message'
]))
{
return
null
;
}
return
$errors
[
0
];
}
/**
* {@inheritdoc}
*/
public
function
execute
(
$params
=
null
)
{
if
(
$params
)
{
$hasZeroIndex
=
isset
(
$params
[
0
]);
foreach
(
$params
as
$key
=>
$val
)
{
if
(
$hasZeroIndex
&&
is_numeric
(
$key
))
{
$this
->
bindValue
(
$key
+
1
,
$val
);
}
else
{
$this
->
bindValue
(
$key
,
$val
);
}
}
}
// prepare statement
$this
->
_sth
=
sqlsrv_prepare
(
$this
->
_dbh
,
$this
->
_query
,
$this
->
_bindParams
);
if
(
!
$this
->
_sth
)
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
$ret
=
@
sqlsrv_execute
(
$this
->
_sth
);
if
(
!
$ret
)
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
return
$ret
;
}
/**
* {@inheritdoc}
*/
public
function
fetch
(
$fetchStyle
=
PDO
::
FETCH_BOTH
)
{
if
(
!
isset
(
self
::
$fetchStyleMap
[
$fetchStyle
]))
{
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetchStyle
);
}
$result
=
sqlsrv_fetch_array
(
$this
->
_sth
,
self
::
$fetchStyleMap
[
$fetchStyle
]);
if
(
!
$result
)
{
return
false
;
}
else
{
return
$result
;
}
}
/**
* {@inheritdoc}
*/
public
function
fetchAll
(
$fetchStyle
=
PDO
::
FETCH_BOTH
)
{
if
(
!
isset
(
self
::
$fetchStyleMap
[
$fetchStyle
]))
{
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetchStyle
);
}
$result
=
array
();
while
(
$row
=
$this
->
fetch
(
$fetchStyle
))
{
$result
[]
=
$row
;
}
return
$result
;
}
/**
* {@inheritdoc}
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
{
if
(
sqlsrv_fetch
(
$this
->
_sth
)
===
false
)
{
throw
SqlsrvException
::
fromErrorInfo
(
$this
->
errorInfo
());
}
return
sqlsrv_get_field
(
$this
->
_sth
,
$columnIndex
);
}
/**
* {@inheritdoc}
*/
public
function
rowCount
()
{
return
sqlsrv_rows_affected
(
$this
->
_sth
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/DriverManager.php
View file @
e2dd9536
...
...
@@ -45,7 +45,6 @@ final class DriverManager
'ibm_db2'
=>
'Doctrine\DBAL\Driver\IBMDB2\DB2Driver'
,
'pdo_ibm'
=>
'Doctrine\DBAL\Driver\PDOIbm\Driver'
,
'pdo_sqlsrv'
=>
'Doctrine\DBAL\Driver\PDOSqlsrv\Driver'
,
'sqlsrv'
=>
'Doctrine\DBAL\Driver\Sqlsrv\Driver'
,
);
/** Private constructor. This class cannot be instantiated. */
...
...
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