Convert many comments to phpdoc style, and document some more functions
[lhc/web/wiklou.git] / includes / Database.php
index a0e62f9..9e32024 100644 (file)
@@ -429,11 +429,13 @@ class Database {
        function affectedRows() { return mysql_affected_rows( $this->mConn ); }
        /**#@-*/ // end of template : @param $result
 
-
        /**
         * Simple UPDATE wrapper
         * Usually aborts on failure
         * If errors are explicitly ignored, returns success
+        *
+        * This function exists for historical reasons, Database::update() has a more standard 
+        * calling convention and feature set
         */
        function set( $table, $var, $value, $cond, $fname = 'Database::set' )
        {
@@ -818,7 +820,7 @@ class Database {
         */
        function selectDB( $db ) {
                $this->mDBname = $db;
-               mysql_select_db( $db, $this->mConn );
+               return mysql_select_db( $db, $this->mConn );
        }
 
        /**
@@ -932,7 +934,7 @@ class Database {
                        $rows = array( $rows );
                }
 
-               $sql = "REPLACE INTO $table (" . implode( ',', array_flip( $rows[0] ) ) .') VALUES ';
+               $sql = "REPLACE INTO $table (" . implode( ',', array_keys( $rows[0] ) ) .') VALUES ';
                $first = true;
                foreach ( $rows as $row ) {
                        if ( $first ) {
@@ -1041,6 +1043,19 @@ class Database {
                return ' LIMIT '.(is_numeric($offset)?"{$offset},":"")."{$limit} ";
        }
 
+       /**
+        * Returns an SQL expression for a simple conditional.
+        * Uses IF on MySQL.
+        *
+        * @param string $cond SQL expression which will result in a boolean value
+        * @param string $trueVal SQL expression to return if true
+        * @param string $falseVal SQL expression to return if false
+        * @return string SQL fragment
+        */
+       function conditional( $cond, $trueVal, $falseVal ) {
+               return " IF($cond, $trueVal, $falseVal) ";
+       }
+
        /**
         * @todo document
         */
@@ -1196,6 +1211,27 @@ class Database {
                        return new ResultWrapper( $this, $result );
                }
        }
+
+       /**
+        * Return aggregated value alias
+        */
+       function aggregateValue ($valuedata,$valuename='value') {
+               return $valuename;
+       }
+       
+       /**
+        * @return string wikitext of a link to the server software's web site
+        */
+       function getSoftwareLink() {
+               return "[http://www.mysql.com/ MySQL]";
+       }
+       
+       /**
+        * @return string Version information from the database
+        */
+       function getServerVersion() {
+               return mysql_get_server_info();
+       }
 } 
 
 /**