Split of query from query text generation. This makes creating sql statements for...
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 13 May 2008 04:56:14 +0000 (04:56 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 13 May 2008 04:56:14 +0000 (04:56 +0000)
includes/Database.php

index 9efc395..6b8e9b0 100644 (file)
@@ -945,6 +945,24 @@ class Database {
         */
        function select( $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() )
        {
+               $sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds );
+               return $this->query( $sql, $fname );
+       }
+       
+       /**
+        * SELECT wrapper
+        *
+        * @param mixed  $table   Array or string, table name(s) (prefix auto-added)
+        * @param mixed  $vars    Array or string, field name(s) to be retrieved
+        * @param mixed  $conds   Array or string, condition(s) for WHERE
+        * @param string $fname   Calling function name (use __METHOD__) for logs/profiling
+        * @param array  $options Associative array of options (e.g. array('GROUP BY' => 'page_title')),
+        *                        see Database::makeSelectOptions code for list of supported stuff
+        * @param array $join_conds Associative array of table join conditions (optional)
+        *                        (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
+        * @return string, the SQL text
+        */
+       function selectSQLText( $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() ) {
                if( is_array( $vars ) ) {
                        $vars = implode( ',', $vars );
                }
@@ -985,7 +1003,7 @@ class Database {
                if (isset($options['EXPLAIN'])) {
                        $sql = 'EXPLAIN ' . $sql;
                }
-               return $this->query( $sql, $fname );
+               return $sql;
        }
 
        /**