From: Aaron Schulz Date: Tue, 13 May 2008 04:56:14 +0000 (+0000) Subject: Split of query from query text generation. This makes creating sql statements for... X-Git-Tag: 1.31.0-rc.0~47681 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=dbfd6936079e61ec558a74e478c63ee8ed01e000;p=lhc%2Fweb%2Fwiklou.git Split of query from query text generation. This makes creating sql statements for UNIONs much easier. --- diff --git a/includes/Database.php b/includes/Database.php index 9efc395965..6b8e9b050e 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -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; } /**