]> source.dussan.org Git - nextcloud-server.git/commitdiff
documentation added and trying to fix minor code issues
authorThomas Mueller <thomas.mueller@tmit.eu>
Tue, 19 Mar 2013 17:52:54 +0000 (18:52 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Tue, 19 Mar 2013 17:52:54 +0000 (18:52 +0100)
lib/db.php
lib/db/mdb2schemareader.php
lib/db/schema.php

index 379cb342db5abe286bed9fdbe7b00ef6c2355e74..951c21f4146c73d11c1fb9ca2fedddd0abd6a302 100644 (file)
@@ -196,6 +196,7 @@ class OC_DB {
         * @param string $query Query string
         * @param int $limit
         * @param int $offset
+        * @throws DatabaseException
         * @return \Doctrine\DBAL\Statement prepared SQL query
         *
         * SQL query via Doctrine prepare(), needs to be execute()'d!
@@ -235,7 +236,7 @@ class OC_DB {
                        try {
                                $result=self::$connection->prepare($query);
                        } catch(\Doctrine\DBAL\DBALException $e) {
-                               throw new DatabaseException($e->getMessage(), $query);
+                               throw new \DatabaseException($e->getMessage(), $query);
                        }
                        $result=new DoctrineStatementWrapper($result);
                }
@@ -338,6 +339,7 @@ class OC_DB {
        /**
         * @brief update the database scheme
         * @param string $file file to read structure from
+        * @throws Exception
         * @return bool
         */
        public static function updateDbFromStructure($file) {
@@ -367,7 +369,7 @@ class OC_DB {
         * @brief Insert a row if a matching row doesn't exists.
         * @param string $table. The table to insert into in the form '*PREFIX*tableName'
         * @param array $input. An array of fieldname/value pairs
-        * @returns The return value from DoctrineStatementWrapper->execute()
+        * @return bool return value from DoctrineStatementWrapper->execute()
         */
        public static function insertIfNotExist($table, $input) {
                self::connect();
@@ -398,6 +400,7 @@ class OC_DB {
                                OC_Log::write('core', $entry, OC_Log::FATAL);
                                error_log('DB error: '.$entry);
                                OC_Template::printErrorPage( $entry );
+                               return false;
                        }
 
                        if($result->numRows() == 0) {
@@ -430,6 +433,7 @@ class OC_DB {
                        OC_Log::write('core', $entry, OC_Log::FATAL);
                        error_log('DB error: ' . $entry);
                        OC_Template::printErrorPage( $entry );
+                       return false;
                }
 
                return $result->execute();
@@ -556,7 +560,7 @@ class OC_DB {
        }
 
        /**
-        * @brief replaces the owncloud tables with a new set
+        * @brief replaces the ownCloud tables with a new set
         * @param $file string path to the MDB2 xml db export file
         */
        public static function replaceDB( $file ) {
@@ -799,6 +803,7 @@ class DoctrineStatementWrapper {
         * Provide a simple fetchOne.
         * fetch single column from the next row
         * @param int $colnum the column number to fetch
+        * @return string
         */
        public function fetchOne($colnum = 0) {
                return $this->statement->fetchColumn($colnum);
index 53eb849d86a3817588e7a0f6f605a17c953ef4ca..7a7efe551c11c030e89d4c5a5d54e1fd9db122bd 100644 (file)
@@ -11,6 +11,12 @@ class OC_DB_MDB2SchemaReader {
        static protected $DBTABLEPREFIX;
        static protected $platform;
 
+       /**
+        * @param $file
+        * @param $platform
+        * @return \Doctrine\DBAL\Schema\Schema
+        * @throws DomainException
+        */
        public static function loadSchemaFromFile($file, $platform) {
                self::$DBNAME  = OC_Config::getValue( "dbname", "owncloud" );
                self::$DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
@@ -38,6 +44,11 @@ class OC_DB_MDB2SchemaReader {
                return $schema;
        }
 
+       /**
+        * @param\Doctrine\DBAL\Schema\Schema $schema
+        * @param $xml
+        * @throws DomainException
+        */
        private static function loadTable($schema, $xml) {
                foreach($xml->children() as $child) {
                        switch($child->getName()) {
@@ -60,6 +71,11 @@ class OC_DB_MDB2SchemaReader {
                }
        }
 
+       /**
+        * @param \Doctrine\DBAL\Schema\Table $table
+        * @param $xml
+        * @throws DomainException
+        */
        private static function loadDeclaration($table, $xml) {
                foreach($xml->children() as $child) {
                        switch($child->getName()) {
index 8941881d4eac08ca28f65c12e70441d10506dac5..37379f606635cc8402a386927f7c0ea708cfea3e 100644 (file)
@@ -101,19 +101,19 @@ class OC_DB_Schema {
        }
 
        /**
-        * @brief replaces the owncloud tables with a new set
+        * @brief replaces the ownCloud tables with a new set
         * @param $file string path to the MDB2 xml db export file
         */
        public static function replaceDB( $conn, $file ) {
                $apps = OC_App::getAllApps();
                self::beginTransaction();
                // Delete the old tables
-               self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' );
+               self::removeDBStructure( $conn, OC::$SERVERROOT . '/db_structure.xml' );
 
                foreach($apps as $app) {
                        $path = OC_App::getAppPath($app).'/appinfo/database.xml';
                        if(file_exists($path)) {
-                               self::removeDBStructure( $path );
+                               self::removeDBStructure( $conn, $path );
                        }
                }