Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
die_coolen_jungs
our_own_cloud_project
Commits
1ea43dd7
Commit
1ea43dd7
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
make OC_DB work with the sqlite3 driver
parent
600219c8
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
lib/database.php
+8
-6
8 additions, 6 deletions
lib/database.php
with
8 additions
and
6 deletions
lib/database.php
+
8
−
6
View file @
1ea43dd7
...
@@ -60,10 +60,10 @@ class OC_DB {
...
@@ -60,10 +60,10 @@ class OC_DB {
'quote_identifier'
=>
true
);
'quote_identifier'
=>
true
);
// Add the dsn according to the database type
// Add the dsn according to the database type
if
(
$CONFIG_DBTYPE
==
'sqlite'
){
if
(
$CONFIG_DBTYPE
==
'sqlite'
or
$CONFIG_DBTYPE
==
'sqlite3'
){
// sqlite
// sqlite
$dsn
=
array
(
$dsn
=
array
(
'phptype'
=>
'sqlite'
,
'phptype'
=>
$CONFIG_DBTYPE
,
'database'
=>
"
$datadir
/
$CONFIG_DBNAME
.db"
,
'database'
=>
"
$datadir
/
$CONFIG_DBNAME
.db"
,
'mode'
=>
'0644'
);
'mode'
=>
'0644'
);
}
}
...
@@ -100,6 +100,9 @@ class OC_DB {
...
@@ -100,6 +100,9 @@ class OC_DB {
// We always, really always want associative arrays
// We always, really always want associative arrays
self
::
$DBConnection
->
setFetchMode
(
MDB2_FETCHMODE_ASSOC
);
self
::
$DBConnection
->
setFetchMode
(
MDB2_FETCHMODE_ASSOC
);
//we need to function module for query pre-procesing
self
::
$DBConnection
->
loadModule
(
'Function'
);
}
}
// we are done. great!
// we are done. great!
...
@@ -297,15 +300,14 @@ class OC_DB {
...
@@ -297,15 +300,14 @@ class OC_DB {
* and replaces the ` woth ' or " according to the database driver.
* and replaces the ` woth ' or " according to the database driver.
*/
*/
private
static
function
processQuery
(
$query
){
private
static
function
processQuery
(
$query
){
self
::
connect
();
// We need Database type and table prefix
// We need Database type and table prefix
$CONFIG_DBTYPE
=
OC_CONFIG
::
getValue
(
"dbtype"
,
"sqlite"
);
$CONFIG_DBTYPE
=
OC_CONFIG
::
getValue
(
"dbtype"
,
"sqlite"
);
$CONFIG_DBTABLEPREFIX
=
OC_CONFIG
::
getValue
(
"dbtableprefix"
,
"oc_"
);
$CONFIG_DBTABLEPREFIX
=
OC_CONFIG
::
getValue
(
"dbtableprefix"
,
"oc_"
);
// differences is getting the current timestamp
// differences is getting the current timestamp
if
(
$CONFIG_DBTYPE
==
'sqlite'
){
$query
=
str_replace
(
'NOW()'
,
self
::
$DBConnection
->
now
(),
$query
);
$query
=
str_replace
(
'NOW()'
,
"strftime('%s', 'now')"
,
$query
);
$query
=
str_replace
(
'now()'
,
self
::
$DBConnection
->
now
(),
$query
);
$query
=
str_replace
(
'now()'
,
"strftime('%s', 'now')"
,
$query
);
}
// differences in escaping of table names (` for mysql)
// differences in escaping of table names (` for mysql)
// Problem: what if there is a ` in the value we want to insert?
// Problem: what if there is a ` in the value we want to insert?
...
...
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