Set up the right rule get now 500 error
$db->setQuery("UPDATE #__customers (customers_default_address_id)
开发者_StackOverflow中文版 SET (customers_default_address_id = address_book_id
FROM #__address_book WHERE customers_id = '.(int) $userId.')");
With this rule I get a 500 error. What should be the error?
I think this should solve the problem
$address_id = tep_db_insert_id();
$db->setQuery(" UPDATE #_customers
SET customers_default_address_id = '" . (int)$address_id . "'
where customers_id = '" . (int) $userId . "'");
$db->query();
You have an error in your UPDATE
syntax:
$user_id = mysql_real_escape_string($user_id);
$db->setQuery("UPDATE customers c
INNER JOIN address_book ab ON (...join-criterion_here...)
SET c.customers_default_address_id = ab.address_book_id
WHERE c.customers_id = '$user_id' ");
Also the '.(int) $user_id.'
trick doesn't work in my tests.
精彩评论