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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
410c6bba
Commit
410c6bba
authored
13 years ago
by
Jan-Christoph Borchardt
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitorious.org:owncloud/owncloud
parents
8d203531
f073041b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/db.php
+35
-2
35 additions, 2 deletions
lib/db.php
with
35 additions
and
2 deletions
lib/db.php
+
35
−
2
View file @
410c6bba
...
...
@@ -263,7 +263,7 @@ class OC_DB {
*
* TODO: write more documentation
*/
public
static
function
getDbStructure
(
$file
){
public
static
function
getDbStructure
(
$file
,
$mode
=
MDB2_SCHEMA_DUMP_STRUCTURE
){
self
::
connectScheme
();
// write the scheme
...
...
@@ -299,7 +299,7 @@ class OC_DB {
$file2
=
tempnam
(
get_temp_dir
(),
'oc_db_scheme_'
);
$content
=
str_replace
(
'*dbname*'
,
$CONFIG_DBNAME
,
$content
);
$content
=
str_replace
(
'*dbprefix*'
,
$CONFIG_DBTABLEPREFIX
,
$content
);
if
(
$CONFIG_DBTYPE
==
'pgsql'
){
//mysql support it too but sqlite don't
if
(
$CONFIG_DBTYPE
==
'pgsql'
){
//mysql support it too but sqlite do
es
n't
$content
=
str_replace
(
'<default>0000-00-00 00:00:00</default>'
,
'<default>CURRENT_TIMESTAMP</default>'
,
$content
);
}
file_put_contents
(
$file2
,
$content
);
...
...
@@ -327,6 +327,39 @@ class OC_DB {
return
true
;
}
/**
* @brief update the database scheme
* @param $file file to read structure from
*/
public
static
function
updateDbFromStructure
(
$file
){
$CONFIG_DBNAME
=
OC_Config
::
getValue
(
"dbname"
,
"owncloud"
);
$CONFIG_DBTABLEPREFIX
=
OC_Config
::
getValue
(
"dbtableprefix"
,
"oc_"
);
$CONFIG_DBTYPE
=
OC_Config
::
getValue
(
"dbtype"
,
"sqlite"
);
self
::
connectScheme
();
// read file
$content
=
file_get_contents
(
$file
);
// Make changes and save them to a temporary file
$file2
=
tempnam
(
get_temp_dir
(),
'oc_db_scheme_'
);
$content
=
str_replace
(
'*dbname*'
,
$CONFIG_DBNAME
,
$content
);
$content
=
str_replace
(
'*dbprefix*'
,
$CONFIG_DBTABLEPREFIX
,
$content
);
if
(
$CONFIG_DBTYPE
==
'pgsql'
){
//mysql support it too but sqlite doesn't
$content
=
str_replace
(
'<default>0000-00-00 00:00:00</default>'
,
'<default>CURRENT_TIMESTAMP</default>'
,
$content
);
}
file_put_contents
(
$file2
,
$content
);
$previousSchema
=
self
::
$schema
->
getDefinitionFromDatabase
();
$op
=
$schema
->
updateDatabase
(
$file2
,
$previousSchema
,
array
(),
false
);
if
(
PEAR
::
isError
(
$op
))
{
$error
=
$op
->
getMessage
();
OC_Log
::
write
(
'core'
,
'Failed to update database structure ('
.
$error
.
')'
,
OC_Log
::
FATAL
);
return
false
;
}
return
true
;
}
/**
* @brief connects to a MDB2 database scheme
* @returns true/false
...
...
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