duanmei1850 2016-06-10 08:04
浏览 35
已采纳

将POST存储在新变量中或使用$ _POST

Usually I call the POST method directly $_POST but if I assign the $_POST variable in new variable will the process speed faster? for example

method 1

/* $this->input->post('name') */
$this->db->where("name=".$this->input->post('name'));
$this->db->update(table, $this->input->post('name'));
$this->session->userdata(array("formdata", $this->input->post()));

method 2

$name = $this->input->post('name');
$this->db->where("name=".$name);
$this->db->update(table, $name);
$this->session->userdata(array("formdata", $this->input->post()));

Which method process faster?

Note: Sorry I don't understand how the process work in depth. I've around 30 input. Above query is just an example. There are multiple filter and processing section before sql insert/update. From what I know $_POST is a function and it take more resource than variable/array. I think using variable or array make the processing speed faster.a

  • 写回答

1条回答 默认 最新

  • douxiawei9318 2016-06-10 08:23
    关注

    The most efficient and better way is

    Generates an update string and runs the query based on the data you supply. You can pass an array or an object to the function. Here is an example using an array:

    $data = array(
            'title' => $this->input->post('title'),
            'name' => $this->input->post('name'),
            'date' => $this->input->post('date'),
          // ....... and soo ON.........
    );
    
    $this->db->where('id', $this->input->post('title'));
    $this->db->update('mytable', $data);
    

    Read updating-data

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度