You can call a subQuery function where
((SELECT value_2 FROM other_table WHERE id = 2) + 1)
will be executed and be used on the same model.
Example:
Controller:
$this->load->model('example_model');
$this->example_model->mainQuery();
Model:
Class Example_model Extends CI_Model
{
function subQuery()
{
$query = "SELECT value_2 FROM other_table WHERE id = 2;
$q = $this->db->query($query);
$this->mainQuery($q->result());
}
function mainQuery($subQuery)
{
$query = "UPDATE some_table SET value_1 = "'.$subQuery.'" WHERE id = 2";
$this->db->query($query);
}
}
If you want to use the active record(recommended) instead of queries. You can start translating your queries to active records by reading
this one.