I have the following function in one of my CI models:
function update_uu_feature($feature, $lang, $data)
{
$feature = str_replace('_', '-', $feature);
$this->db->where('navigation', $feature);
$this->db->where('language', $lang);
$this->db->join('all_video_names', 'all_video_names.video_id = all_uu_features.video_id', 'inner');
return $this->db->update('all_uu_features', $data);
}
But the “join” line gets discarded. In the profiler, it outputs:
UPDATE `all_uu_features` SET `page_title` = 'Laser', `title` = 'Test', `keywords` = 'Test', `description` = 'Test', `feature_text` = '<p>Test text</p>', `learn_more_about` = 'Test Text 2', `overview` = 'test', `copy` = 'test' WHERE `navigation` = 'laser-interface' AND `language` = 'en'
Can someone help me with the syntax? Thanks. Most of the data is in the all_uu_features table, except for the video name, which is in the all_video_names table. The two are joined on the video_id column in each table. In other words, all of the columns in the above statement are in all_uu_features except for video name. Hope that's clear.
The SQL statement above shows the data is being returned in the post and being processed by the function, it's just not accepting the join for some reason.
It looks to me very much like CI's Active Record class doesn't support using joins in its update() operation. Certainly if you have a look at the code (in DB_active_rec.php), the update()
method doesn't even look at any joins that have been set up
From update():
$sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);