Column 'XXX' specified twice??

twscott

Member
Hi,
This is strange that I've test the PHP plugin in my local site, everything was alright, but I when copied it to the server, I got this erroe message :
1110 Column 'group_id' specified twice SQL=INSERT INTO `#__user_usergroup_map` SET `user_id` = '571' , `group_id` = '26' , `user_id` = '' , `group_id` = ''

and following is my source code:
function newUser_UserGroupMap($juseid, $groupID, $db, $query){
$query->insert($db->quoteName('#__user_usergroup_map')) ->set($db->quoteName('user_id').' = ' . $db->quote($juseid)) ->set($db->quoteName('group_id').' = ' . $db->quote($groupID));
$db->setQuery($query);
$db->execute();
}

Can anyone give me a direction? Thanks

Best regards
Scott
 
or ...

Code:
$query->clear();

If you aren't specifically fetching a new, empty query with getQuery(true), and aren't deliberately adding terms to an existing query, you should always clear() it before use.

So in this case, your function is probably getting called twice, once with empty values, and the set() methods are additive.

So you should probably also figure out why your function is getting called twice.

-- hugh
 
By the way, I have another question about displaying messages.
I am using Chinese character set, when I display the message by
JFactory::getApplication()->enqueueMessage('** XXXXX ***** ', 'warning');
It works fine in my developing site but again in the product site, the Chinese code just don't show properly.
The two sites was backup/restore from each other, they are totally identical, what could cause this problem?
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top