Welcome Guest, Not a member yet? Register   Sign In
Support JOIN in UPDATE
#1

PHP 8.2
MySQL 8.2
Apache 2.4
CI 4.5.1

With the code
PHP Code:
$builder $this->db->table('attribute_links');
$builder->join('attribute_values''attribute_values.attribute_id = attribute_links.attribute_id''inner');
$builder->set('attribute_links.attribute_id'"IF((attribute_values.attribute_value IN('false','0','') OR (attribute_values.attribute_value IS NULL)), $checkbox_attribute_values[0]$checkbox_attribute_values[1])"false);
$builder->where('attribute_links.definition_id'$definition_id);
log_message('error'$builder->getCompiledUpdate(false)); 

I expect the generated SQL to be
Code:
UPDATE `ospos_attribute_links`
JOIN `ospos_attribute_values` ON `ospos_attribute_values`.`attribute_id` = `ospos_attribute_links`.`attribute_id`
SET `ospos_attribute_links`.`attribute_id` = IF((`ospos_attribute_values`.`attribute_value` IN('false','0','') OR (`ospos_attribute_values`.`attribute_value` IS NULL)), 45873, 25595)
WHERE `ospos_attribute_links`.`definition_id` = 6

What I get is
Code:
UPDATE `ospos_attribute_links`
SET `ospos_attribute_links`.`attribute_id` = IF((attribute_values.attribute_value IN('false','0','') OR (attribute_values.attribute_value IS NULL)), 45873, 25595)
WHERE `ospos_attribute_links`.`definition_id` = 6

This is completely missing the join. Your batch update (https://codeigniter.com/user_guide/datab...-from-data) examples shows joins being generated in an update, so I know it's possible, but doesn't seem to be implemented.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB