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
222724f7
Commit
222724f7
authored
Sep 22, 2006
by
elliot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a leaner dsn parser for consideration
parent
8ea7b0b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
DB.php
draft/DB.php
+47
-0
No files found.
draft/DB.php
View file @
222724f7
...
...
@@ -472,5 +472,52 @@ class Doctrine_DB implements Countable, IteratorAggregate {
return
$parsed
;
}
/**
* Here is my version of parseDSN. It is a bit leaner than the one above, but you can choose either one.
* This one relies on the built in functionality more than replicating it in userland code so it should
* be more efficient. Not completely compatible with the parser above, but it is easy to add in
* the phptype/dbsyntax and protocol/hostspec parts if need be.
*
* @author Elliot Anderson <elliot.a@gmail.com>
*
* @param string $dsn
* @return array Parsed contents of DSN
*/
function
parseDSNnew
(
$dsn
)
{
$parts
=
parse_url
(
$dsn
);
$parsed
=
array
(
);
if
(
count
(
$parts
)
==
0
)
return
false
;
if
(
isset
(
$parts
[
'scheme'
]
)
)
$parsed
[
'phptype'
]
=
$parsed
[
'dbsyntax'
]
=
$parts
[
'scheme'
];
if
(
isset
(
$parts
[
'host'
]
)
)
{
if
(
strpos
(
$parts
[
'host'
],
'+'
)
)
{
$tmp
=
explode
(
'+'
,
$parts
[
'host'
]
);
$parsed
[
'protocol'
]
=
$tmp
[
0
];
$parsed
[
'hostspec'
]
=
$tmp
[
1
];
}
else
{
$parsed
[
'hostspec'
]
=
$parts
[
'host'
];
}
}
if
(
isset
(
$parts
[
'path'
]
)
)
$parsed
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
if
(
isset
(
$parts
[
'user'
]
)
)
$parsed
[
'username'
]
=
$parts
[
'user'
];
if
(
isset
(
$parts
[
'pass'
]
)
)
$parsed
[
'password'
]
=
$parts
[
'pass'
];
if
(
isset
(
$parts
[
'query'
]
)
)
parse_str
(
$parts
[
'query'
],
$parsed
[
'options'
]
);
return
$parsed
;
}
}
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