summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php37
1 files changed, 28 insertions, 9 deletions
diff --git a/lib/db.php b/lib/db.php
index 4c17cd0dbd1..9fab51edfcd 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -316,8 +316,8 @@ class OC_DB {
// read file
$content = file_get_contents( $file );
- // Make changes and save them to a temporary file
- $file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
+ // Make changes and save them to an in-memory file
+ $file2 = 'static://db_scheme';
if($file2 == ''){
die('could not create tempfile in get_temp_dir() - aborting');
}
@@ -331,7 +331,7 @@ class OC_DB {
// Try to create tables
$definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
- // Delete our temporary file
+ //clean up memory
unlink( $file2 );
// Die in case something went wrong
@@ -371,8 +371,8 @@ class OC_DB {
return false;
}
- // Make changes and save them to a temporary file
- $file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
+ // Make changes and save them to an in-memory file
+ $file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $previousSchema['name'], $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't
@@ -381,7 +381,7 @@ class OC_DB {
file_put_contents( $file2, $content );
$op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
- // Delete our temporary file
+ //clean up memory
unlink( $file2 );
if (PEAR::isError($op)) {
@@ -508,6 +508,21 @@ class OC_DB {
self::$connection->commit();
self::$inTransaction=false;
}
+
+ /**
+ * check if a result is an error, works with MDB2 and PDOException
+ * @param mixed $result
+ * @return bool
+ */
+ public static function isError($result){
+ if(!$result){
+ return true;
+ }elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)){
+ return true;
+ }else{
+ return false;
+ }
+ }
}
/**
@@ -527,11 +542,15 @@ class PDOStatementWrapper{
public function execute($input=array()){
$this->lastArguments=$input;
if(count($input)>0){
- $this->statement->execute($input);
+ $result=$this->statement->execute($input);
+ }else{
+ $result=$this->statement->execute();
+ }
+ if($result){
+ return $this;
}else{
- $this->statement->execute();
+ return false;
}
- return $this;
}
/**