diff -urN views_alt/views.module views/views.module --- views_alt/views.module 2006-06-26 03:03:01.000000000 +0200 +++ views/views.module 2006-07-27 00:17:25.000000000 +0200 @@ -848,7 +848,7 @@ */ function _views_is_cacheable(&$view) { // views with arguments are immediately not cacheable. - if (!empty($view->argument) || !empty($view->exposed_filter)) { + if (!empty($view->argument) || !empty($view->exposed_filter) || !empty($view->no_cache)) { return false; } diff -urN views_alt/views_query.inc views/views_query.inc --- views_alt/views_query.inc 2006-06-26 03:03:01.000000000 +0200 +++ views/views_query.inc 2006-07-27 00:17:33.000000000 +0200 @@ -6,6 +6,7 @@ */ function _views_build_query(&$view, $args = array()) { $query = new _views_query(); + $query->use_alias_prefix = $view->use_alias_prefix; // Process static filters _views_view_build_filters($query, $view); @@ -84,6 +85,10 @@ foreach($view->exposed_filter as $count => $expose) { if ($filter['id'] == $expose['id']) { $id = $expose['id']; + + if (isset($view->exposed_filter_offset)) { + $count += $view->exposed_filter_offset; + } if (!$expose['operator'] && $_GET["op$count"]) { $filter['operator'] = check_plain($_GET["op$count"]); @@ -124,7 +129,7 @@ $not = "NOT"; } $query->ensure_table($table); - $where_args = array_merge(array($table, $field), $filter['value']); + $where_args = array_merge(array($query->use_alias_prefix . $table, $field), $filter['value']); $placeholder = array_fill(0, count($filter['value']), '%s'); $query->add_where("%s.%s $not IN ('". implode("','", $placeholder) ."')", $where_args); } @@ -145,7 +150,7 @@ } else { $query->ensure_table("$table"); - $query->add_where("%s.%s %s '%s'", $table, $field, $filter['operator'], $filter['value']); + $query->add_where("%s.%s %s '%s'", $query->use_alias_prefix . $table, $field, $filter['operator'], $filter['value']); } } } @@ -260,6 +265,7 @@ */ function _views_query($views_get_title_table = 'node', $views_get_title_field = 'nid') { $this->views_get_title_table = $views_get_title_table; + $this->joins = array(); $this->where = array(); $this->orderby = array(); $this->groupby = array(); @@ -273,6 +279,7 @@ } $this->count_field = "$views_get_title_table.$views_get_title_field"; $this->header = array(); + $this->use_alias_prefix = ''; } /* @@ -291,9 +298,9 @@ $table .= "."; } if ($alias) { - $a = " AS $alias"; + $a = " AS $this->use_alias_prefix$alias"; } - $this->fields[] = "$table$field$a"; + $this->fields[] = "$this->use_alias_prefix$table$field$a"; } /* @@ -438,7 +445,7 @@ else { $this->tables[$table]++; } - $this->tablequeue[] = array('table' => $table, 'num' => $this->tables[$table]); + $this->tablequeue[] = array('table' => $table, 'num' => $this->tables[$table], 'alias_prefix' => $this->use_alias_prefix); } /* @@ -498,9 +505,11 @@ * The name of the table in the global table array. * @param $table_num * The instance number of the table. + * @param $alias_prefix + * An optional prefix for the table alias. */ - function get_table_name($table, $table_num) { - return ($table_num < 2 ? $table : $table . $table_num); + function get_table_name($table, $table_num, $alias_prefix = '') { + return ($table_num < 2 ? $alias_prefix . $table : $alias_prefix . $table . $table_num); } /* @@ -521,15 +530,18 @@ $table_real = (isset($table_data[$table]['name']) ? $table_data[$table]['name'] : $table); $table_num = $tinfo['num']; - $table_alias = $this->get_table_name($table, $table_num); + $table_alias = $this->get_table_name($table, $table_num, $tinfo['alias_prefix']); $joininfo = (!$this->joins[$table][$table_num] ? $table_data[$table]['join'] : $this->joins[$table][$table_num]); + + $left_table_alias = isset($joininfo['left']['alias']) ? $joininfo['left']['alias'] : $tinfo['alias_prefix']; + $left_table_alias .= $joininfo['left']['table']; // the { is a special character which seems to be treated differently // in PHP5 than PHP4 so we do this a little oddly. $join_type = $joininfo['type'] == 'inner' ? 'INNER' : 'LEFT'; - $joins .= " $join_type JOIN {" . $table_real . "} $table_alias ON " . $joininfo['left']['table'] . "." . + $joins .= " $join_type JOIN {" . $table_real . "} $table_alias ON " . $left_table_alias .".". $joininfo['left']['field'] . " = $table_alias." . $joininfo['right']['field']; if (isset($joininfo['extra'])) {