I am trying to help out a preschool with their annual fundraising auction. Everything else is fine but when I try to make a view for them so that they can see what the current high bids are it gives the errors below and doesn't show the products. I am adding the "Product: High bid" in Views 2. Everything is current in terms of modules. Latest Drupal 6 etc. Any help would be greatly appreciated.

Thanks,

Michael

Errors:

user warning: Unknown column 'uc_auction.high_bid' in 'on clause' query: SELECT COUNT(*) FROM (SELECT DISTINCT node.nid AS nid FROM node node LEFT JOIN uc_auction_bids uc_auction_bids ON uc_auction.high_bid = uc_auction_bids.bid LEFT JOIN uc_auction uc_auction ON node.nid = uc_auction.nid WHERE (node.status <> 0) AND (node.type IN ('product','auction')) ) count_alias in /XXXXXXXXXXXX/modules/views/includes/view.inc on line 745.

user warning: Unknown column 'uc_auction.high_bid' in 'on clause' query: SELECT DISTINCT node.nid AS nid, node.type AS node_type, node.title AS node_title, uc_auction.start_price AS uc_auction_start_price, uc_auction_bids.amount AS uc_auction_bids_amount FROM node node LEFT JOIN uc_auction_bids uc_auction_bids ON uc_auction.high_bid = uc_auction_bids.bid LEFT JOIN uc_auction uc_auction ON node.nid = uc_auction.nid WHERE (node.status <> 0) AND (node.type IN ('product','auction')) ORDER BY node_title ASC LIMIT 0, 10 in /XXXXXXXXXXXX/modules/views/includes/view.inc on line 771.

Comments

jasonawant’s picture

Hi Michael,

I haven't used this module yet, but I'm currently evaluating it. Your error message makes me think that you need to define a view relationship to use the product: High bid field. I could be wrong though. You'd have to give it a try. Not familiar with view relationships, watch this: http://gotdrupal.com/videos/drupal-views-relationships.

HTH
jwant

acontia’s picture

Hi,

I had the same problem and I have resolved it with a not very clean solution... but works and you don't need to patch the module.

I've installed the Views Custom Field module, which allows you to get custom fields in a view.

Once installed and enabled you can add a new custom field "customfield > Customfield: PHP code". In the "value" field write this php code:

<?php print(custom_high_bid($data->nid)); ?>

and then in your template.php or custom module you define the function:

<?php
function custom_high_bid($nid){
	$node=node_load($nid);
	$amount=$node->uc_auction["high_bid_amt"];
	
	if(!empty($amount)){
		return uc_currency_format($amount);
	}else{
		return uc_currency_format($node->uc_auction["start_price"]);
	}
	
}
?>

The same works for the high bidder

crandallr’s picture

Lifesaver! Thanks!

zilverdistel’s picture

Trying to figure this out. The query I get from views is

SELECT node.nid AS nid, node.type AS node_type, node.vid AS node_vid, uc_auction.start_price AS uc_auction_start_price, uc_auction_bids.amount AS uc_auction_bids_amount 
FROM node node 
LEFT JOIN uc_auction_bids uc_auction_bids 
ON uc_auction.high_bid = uc_auction_bids.bid 
LEFT JOIN uc_auction uc_auction 
ON node.nid = uc_auction.nid 
WHERE 
(node.status <> 0) AND (node.type IN ('product')) AND (node.nid != 2) LIMIT 0, 10

This gives me the error described in the issue above, but when I swap the 2 joins, the query seems to work:

LEFT JOIN uc_auction uc_auction
ON node.nid = uc_auction.nid
LEFT JOIN uc_auction_bids uc_auction_bids
ON uc_auction.high_bid = uc_auction_bids.bid
zilverdistel’s picture

Using the filter Product - 'Is an auction' in my view solved my problem. I was hinted by a comment in 'modules/uc_auction/views/uc_auction_handler_filter_is_auc.inc'.

      // Okay. Calling parent::query() will add a filter to filter on product-
      // ness, as Ubercart's "Is product" filter does. However, if both this
      // filter and that filter are used, the WHERE clause is added twice. To
      // avoid this, we'll check to see if the WHERE clause for "Is product" is
      // already present, and not call parent::query() if that's the case.
      // However, this only works if "Is product" is sorted so it's before "Is
      // an auction!" Hmm.
ermannob’s picture

Thanks zilverdistel. Your solution worked for me.

jepster_’s picture

Status: Active » Fixed

We have a solution, so I set this issue to fixed.

jepster_’s picture

Status: Fixed » Closed (fixed)

closed

Quaranta’s picture

The uc_auction_bids table is called too soon in the query (as described in #4).
I fixed this using hook_views_query_alter:

function YOUR_MODULE_views_query_alter(&$view, &$query) {
  if ($view->name == 'YOUR_VIEW'){
     $bids = $query->table_queue['uc_auction_bids'];
     unset($query->table_queue['uc_auction_bids']);
     $query->table_queue['uc_auction_bids'] = $bids;
  }
}

This moves the uc_auction_bids join to the end of the query, problem solved.

gumol’s picture

I have a problem with sorting by field high_bid. It displays high_bid_amount but sorts by high_bid_id. Any ideas how to fix it to sort by high_bid_amount?