We tried a query with the following script (from line 6 to line 52) and it failed also.
Yes we are trying to use only the mysql integration in cbsubs.
Fatal error: Call to a member function commitTabsContents() on a non-object in /Applications/MAMP/htdocs/activnew/administrator/components/com_comprofiler/library/cb/cb.tables.php on line 1494
Thanks for the tip about Replace, but we would like to use only one query with the cb_cursor, which would be simpler for upgrading ou users.
Code:
DELIMITER ##
#DROP PROCEDURE IF EXISTS curCbupdate;
CREATE PROCEDURE curCbupdate()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE username VARCHAR(255);
DECLARE curSales CURSOR FOR SELECT `user_name` FROM `#__enmasse_sales_person` WHERE `user_name` = "[username]";
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN curSales;
read_loop: LOOP
FETCH curSales INTO username;
IF done THEN
LEAVE read_loop;
END IF;
# UPDATE enmasse_sales_person
IF LENGTH(username)>0 THEN
UPDATE #__enmasse_sales_person SET `name` = "[name]",`address` = "[address]",`phone` = "[phone]",`email` = "[email]",`zip_code` = "[zipcode]",`city` = "[city]",`country` = "[country]", `updated_at` = NOW() WHERE `user_name` = username;
ELSE IF
INSERT INTO `#__enmasse_sales_person`(`name`,`user_name`,`address`,`phone`,`email`,`zip_code`,`city`,`country`,`published`,`created_at`,`updated_at`) VALUES ("[name]","[username]","[address]","[phone]","[email]","[zipcode]","[city]","[country]","1",NOW(),NOW());
END IF;
# UPDATE enmasse_merchant_branch
IF LENGTH(username)>0 THEN
UPDATE `#__enmasse_merchant_branch` SET `name` = '[name]',`branches` = '{"branch1":{"branchname":"branch1","name":"[name]","description":"","google_map_width":"200","google_map_height":"200","address":"[address]","telephone":"[phone]","fax":"[fax]","google_map_lat":"","google_map_long":"","google_map_zoom":""}}' WHERE `user_name` = username;
ELSE IF
INSERT INTO `#__enmasse_merchant_branch`(`name`,`user_name`,`sales_person_id`,`branches`,`zip_code`,`city`,`country`,`published`,`created_at`,`updated_at`) VALUES ('[name]','[username]',(SELECT `id` FROM `#__enmasse_sales_person` WHERE `user_name` = '[username]'),'{"branch1":{"branchname":"branch1","name":"[name]","description":"","google_map_width":"200","google_map_height":"200","address":"[address]","telephone":"[phone]","fax":"[fax]","google_map_lat":"","google_map_long":"","google_map_zoom":""}}','[zipcode]','[city]','[country]','1',NOW(),NOW());
END IF;
# UPDATE user_usergroup_map
IF (SELECT COUNT(`group_id`) FROM `#__user_usergroup_map` WHERE `user_id` = '[user_id]') < 2 THEN
DELETE FROM `#__user_usergroup_map` WHERE `user_id` = '[user_id]';
END IF;
INSERT INTO `#__user_usergroup_map`(`user_id`,`group_id`)
VALUES
('[user_id]', (SELECT `merchant_group` FROM `#__enmasse_setting`)),
('[user_id]', (SELECT `sale_group` FROM `#__enmasse_setting`));
END LOOP;
CLOSE curSales;
END;
CALL curCbupdate;