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
91de30d5
Commit
91de30d5
authored
Oct 24, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bunch of MSSQL issues to get the testsuite running again
parent
52e6fd7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
14 deletions
+66
-14
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+32
-0
MsSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
+24
-0
TestUtil.php
tests/Doctrine/Tests/TestUtil.php
+10
-14
No files found.
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
91de30d5
...
...
@@ -37,6 +37,33 @@ use Doctrine\DBAL\Schema\Index,
*/
class
MsSqlPlatform
extends
AbstractPlatform
{
/**
* {@inheritDoc}
*/
public
function
getDateDiffExpression
(
$date1
,
$date2
)
{
return
'DATEDIFF(day, '
.
$date2
.
','
.
$date1
.
')'
;
}
public
function
getDateAddDaysExpression
(
$date
,
$days
)
{
return
'DATEADD(day, '
.
$days
.
', '
.
$date
.
')'
;
}
public
function
getDateSubDaysExpression
(
$date
,
$days
)
{
return
'DATEADD(day, -1 * '
.
$days
.
', '
.
$date
.
')'
;
}
public
function
getDateAddMonthExpression
(
$date
,
$months
)
{
return
'DATEADD(month, '
.
$months
.
', '
.
$date
.
')'
;
}
public
function
getDateSubMonthExpression
(
$date
,
$months
)
{
return
'DATEADD(month, -1 * '
.
$months
.
', '
.
$date
.
')'
;
}
/**
* Whether the platform prefers identity columns for ID generation.
...
...
@@ -794,4 +821,9 @@ class MsSqlPlatform extends AbstractPlatform
{
return
"["
.
str_replace
(
"]"
,
"]["
,
$str
)
.
"]"
;
}
public
function
getTruncateTableSQL
(
$tableName
,
$cascade
=
false
)
{
return
'TRUNCATE TABLE '
.
$tableName
;
}
}
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
View file @
91de30d5
...
...
@@ -169,4 +169,28 @@ class MsSqlSchemaManager extends AbstractSchemaManager
return
new
View
(
$view
[
'name'
],
null
);
}
/**
* List the indexes for a given table returning an array of Index instances.
*
* Keys of the portable indexes list are all lower-cased.
*
* @param string $table The name of the table
* @return Index[] $tableIndexes
*/
public
function
listTableIndexes
(
$table
)
{
$sql
=
$this
->
_platform
->
getListTableIndexesSQL
(
$table
,
$this
->
_conn
->
getDatabase
());
try
{
$tableIndexes
=
$this
->
_conn
->
fetchAll
(
$sql
);
}
catch
(
\PDOException
$e
)
{
if
(
$e
->
getCode
()
==
"IMSSP"
)
{
return
array
();
}
else
{
throw
$e
;
}
}
return
$this
->
_getPortableTableIndexesList
(
$tableIndexes
,
$table
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/TestUtil.php
View file @
91de30d5
...
...
@@ -70,29 +70,25 @@ class TestUtil
}
else
{
$sm
=
$realConn
->
getSchemaManager
();
$tableNames
=
$sm
->
listTableNames
();
foreach
(
$tableNames
AS
$tableName
)
{
$sm
->
dropTable
(
$tableName
);
}
}
/* @var $schema Schema */
$schema
=
$sm
->
createSchema
();
$stmts
=
$schema
->
toDropSql
(
$realConn
->
getDatabasePlatform
());
$eventManager
=
null
;
if
(
isset
(
$GLOBALS
[
'db_event_subscribers'
]))
{
$eventManager
=
new
\Doctrine\Common\EventManager
();
foreach
(
explode
(
","
,
$GLOBALS
[
'db_event_subscribers'
])
AS
$subscriberClass
)
{
$subscriberInstance
=
new
$subscriberClass
();
$eventManager
->
addEventSubscriber
(
$subscriberInstance
);
foreach
(
$stmts
AS
$stmt
)
{
$realConn
->
exec
(
$stmt
);
}
}
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$realDbParams
,
null
,
$eventManager
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$realDbParams
,
null
,
null
);
}
else
{
$params
=
array
(
'driver'
=>
'pdo_sqlite'
,
'memory'
=>
true
);
if
(
isset
(
$GLOBALS
[
'db_path'
]))
{
$params
[
'path'
]
=
$GLOBALS
[
'db_path'
];
unlink
(
$GLOBALS
[
'db_path'
]);
}
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$params
);
}
...
...
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