开发者

Starting new query context in CodeIgniter's Active Record

I basically wanna do what I'd call nested queries (but not in the nested SELECT way) using CodeIgniter's Active Record.

So it would be like putting aside the current AR context to run a new query before restoring it.

A concrete example:

function handle_form($fields, $POST)
{
  foreach ($开发者_开发百科fields as $field)
  {
    if ($field->type == "file")
      do_upload($field->post);  //This function does insert data in another table using AR too
    $this->db->set($field->name, $POST[$field->post]);
  }
  $this->db->insert('table');
}

I haven't found any resources about that, maybe I'm just using the wrong keywords.. Thanks for your help !


function handle_form($fields, $POST)
{
  $data = array();
  foreach ($fields as $field)
  {
    if ($field->type == "file")
      do_upload($field->post);
    $data[$field->name] = $POST[$field->post];
  }
  $this->db->insert('table', $data);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜