Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Yeray Santana Hualde
syncEnrollments
Commits
6f1f5eed
Commit
6f1f5eed
authored
Jun 11, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow literal path in sqlite database config.
parent
e85e8f95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
connector.php
system/db/connector.php
+22
-11
No files found.
system/db/connector.php
View file @
6f1f5eed
...
...
@@ -22,16 +22,29 @@ class Connector {
*/
public
static
function
connect
(
$config
)
{
// ---------------------------------------------------
//
Establish a SQLite PDO connection
.
// ---------------------------------------------------
// ---------------------------------------------------
--
//
Connect to SQLite
.
// ---------------------------------------------------
--
if
(
$config
->
driver
==
'sqlite'
)
{
return
new
\PDO
(
'sqlite:'
.
APP_PATH
.
'db/'
.
$config
->
database
.
'.sqlite'
,
null
,
null
,
static
::
$options
);
// -----------------------------------------------------
// Check the application/db directory first.
// -----------------------------------------------------
if
(
file_exists
(
$path
=
APP_PATH
.
'db/'
.
$config
->
database
.
'.sqlite'
))
{
return
new
\PDO
(
'sqlite:'
.
$path
,
null
,
null
,
static
::
$options
);
}
// -----------------------------------------------------
// Is the database name the full path?
// -----------------------------------------------------
elseif
(
file_exists
(
$config
->
database
))
{
return
new
\PDO
(
'sqlite:'
.
$config
->
database
,
null
,
null
,
static
::
$options
);
}
}
// ---------------------------------------------------
//
Establish a MySQL or Postgres PDO connection
.
// ---------------------------------------------------
// ---------------------------------------------------
--
//
Connect to MySQL or Postgres
.
// ---------------------------------------------------
--
elseif
(
$config
->
driver
==
'mysql'
or
$config
->
driver
==
'pgsql'
)
{
$connection
=
new
\PDO
(
$config
->
driver
.
':host='
.
$config
->
host
.
';dbname='
.
$config
->
database
,
$config
->
username
,
$config
->
password
,
static
::
$options
);
...
...
@@ -43,10 +56,8 @@ class Connector {
return
$connection
;
}
else
{
throw
new
\Exception
(
'Database driver '
.
$config
->
driver
.
' is not supported.'
);
}
}
}
\ No newline at end of file
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