Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchParapheur
Commits
bd8044c5
Commit
bd8044c5
authored
2 years ago
by
Jean-Laurent DUZANT
Committed by
Guillaume Heurtier
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #23832 TIME 0:20 get databases from json + dev test
parent
fa6af5a2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/models/DatabasePDO.php
+17
-11
17 additions, 11 deletions
src/core/models/DatabasePDO.php
with
17 additions
and
11 deletions
src/core/models/DatabasePDO.php
+
17
−
11
View file @
bd8044c5
...
...
@@ -28,22 +28,27 @@ class DatabasePDO
}
if
(
!
empty
(
$args
[
'configPath'
]))
{
$loade
dXml
=
CoreConfigModel
::
get
Xml
Loaded
([
'path'
=>
$args
[
'configPath'
]
.
'/config.
xml
'
]);
$loade
rJson
=
CoreConfigModel
::
get
Json
Loaded
([
'path'
=>
$args
[
'configPath'
]
.
'/config.
json
'
]);
}
else
{
$loade
dXml
=
CoreConfigModel
::
getConfig
();
$loade
rJson
=
CoreConfigModel
::
getConfig
();
}
if
(
!
$loade
dXml
)
{
if
(
!
$loade
rJson
)
{
throw
new
\Exception
(
'Configuration file can not be read'
);
}
foreach
(
$loadedXml
->
database
as
$key
=>
$database
)
{
$server
=
(
string
)
$database
->
server
;
$port
=
(
string
)
$database
->
port
;
$name
=
(
string
)
$database
->
name
;
$user
=
(
string
)
$database
->
user
;
$password
=
(
string
)
$database
->
password
;
self
::
$type
=
(
string
)
$database
->
type
;
$databases
=
array_filter
(
$loaderJson
,
function
(
$value
,
$key
)
{
return
strpos
(
$key
,
'database'
)
!==
false
;
},
ARRAY_FILTER_USE_BOTH
);
$count
=
1
;
foreach
(
$databases
as
$key
=>
$database
)
{
$server
=
$database
[
'server'
];
$port
=
$database
[
'port'
];
$name
=
$database
[
'name'
];
$user
=
$database
[
'user'
];
$password
=
$database
[
'password'
];
self
::
$type
=
$database
[
'type'
];
$formattedDriver
=
'pgsql'
;
if
(
self
::
$type
==
'POSTGRESQL'
)
{
...
...
@@ -79,7 +84,8 @@ class DatabasePDO
self
::
$pdo
=
new
\PDO
(
$dsn
,
$user
,
$password
,
$options
);
break
;
}
catch
(
\PDOException
$PDOException
)
{
if
(
!
empty
(
$loadedXml
->
{
$key
.
'1'
}))
{
if
(
!
empty
(
$loaderJson
[
$key
.
$count
]))
{
$count
++
;
continue
;
}
else
{
throw
new
\Exception
(
$PDOException
->
getMessage
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment