• <small id='TfRoN'></small><noframes id='TfRoN'>

      <bdo id='TfRoN'></bdo><ul id='TfRoN'></ul>
    <i id='TfRoN'><tr id='TfRoN'><dt id='TfRoN'><q id='TfRoN'><span id='TfRoN'><b id='TfRoN'><form id='TfRoN'><ins id='TfRoN'></ins><ul id='TfRoN'></ul><sub id='TfRoN'></sub></form><legend id='TfRoN'></legend><bdo id='TfRoN'><pre id='TfRoN'><center id='TfRoN'></center></pre></bdo></b><th id='TfRoN'></th></span></q></dt></tr></i><div id='TfRoN'><tfoot id='TfRoN'></tfoot><dl id='TfRoN'><fieldset id='TfRoN'></fieldset></dl></div>
  • <tfoot id='TfRoN'></tfoot>
      <legend id='TfRoN'><style id='TfRoN'><dir id='TfRoN'><q id='TfRoN'></q></dir></style></legend>

        在 Codeigniter 中更新多行

        Updating Multiple Rows in Codeigniter(在 Codeigniter 中更新多行)
        <i id='LqAil'><tr id='LqAil'><dt id='LqAil'><q id='LqAil'><span id='LqAil'><b id='LqAil'><form id='LqAil'><ins id='LqAil'></ins><ul id='LqAil'></ul><sub id='LqAil'></sub></form><legend id='LqAil'></legend><bdo id='LqAil'><pre id='LqAil'><center id='LqAil'></center></pre></bdo></b><th id='LqAil'></th></span></q></dt></tr></i><div id='LqAil'><tfoot id='LqAil'></tfoot><dl id='LqAil'><fieldset id='LqAil'></fieldset></dl></div>
          <tbody id='LqAil'></tbody>
        • <bdo id='LqAil'></bdo><ul id='LqAil'></ul>
        • <tfoot id='LqAil'></tfoot>

              • <legend id='LqAil'><style id='LqAil'><dir id='LqAil'><q id='LqAil'></q></dir></style></legend>
              • <small id='LqAil'></small><noframes id='LqAil'>

                  本文介绍了在 Codeigniter 中更新多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我可以在数据库中插入多行,但问题是当我尝试更新它时,它会给我一个 Codeigniter 错误消息.这是我的模型,实际上我在控制器中没有什么重要的发现错误,是因为我只是在控制器中加载了该模型.

                  I can insert multiple rows in the database, but the problem is when I am trying to update it gives me a Codeigniter error message. Here is my model, actually I have nothing significant in the controller to find an error in, is because I just load that model in controller.

                  $data  = array();
                  //$todayDate = date('Y-m-d');
                  for($i = 1; $i < count($_POST['code']); $i++) {
                      //$code=$_POST['code'][$i];
                      if($_POST['code'][$i] != '') {
                          $data[] = array(
                              $code='code' => $_POST['code'][$i],
                              'price' => $_POST['sell']
                              );
                      }
                  }
                  $linksCount = count($data);
                  
                  if($linksCount) {
                      $this->db->where('code',$code);
                      $this->db->insert_batch('sell_rate', $data);
                  }
                  
                  return $linksCount;
                  

                  推荐答案

                  在你的Model下面的部分应该是

                  In your Model following part should be

                  $data[] = array(
                      $code='code' => $_POST['code'][$i],
                      'price' => $_POST['sell']
                  );
                  

                  替换为

                  $data[] = array(
                      'code' => $_POST['code'][$i],
                      'price' => $_POST['sell']
                  );
                  

                  要更新值,您应该使用 update_batch 而不是 insert_batch

                  and to update the values you should use update_batch instead of insert_batch

                  $this->db->update_batch('yourtableName', $data, 'code'); // 'code' is where key
                  

                  yourtableName 替换为您的原始表名,并且 code 用于 where 键,因此您不需要使用 $this->db->where('code',$code).

                  Replace yourtableName with your original table name and code is being used for where key, so you don't need to use $this->db->where('code',$code).

                  参考: CodeIgniter.

                  这篇关于在 Codeigniter 中更新多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <legend id='JNO7f'><style id='JNO7f'><dir id='JNO7f'><q id='JNO7f'></q></dir></style></legend>

                    1. <small id='JNO7f'></small><noframes id='JNO7f'>

                      <tfoot id='JNO7f'></tfoot>

                          • <bdo id='JNO7f'></bdo><ul id='JNO7f'></ul>
                              <tbody id='JNO7f'></tbody>
                          • <i id='JNO7f'><tr id='JNO7f'><dt id='JNO7f'><q id='JNO7f'><span id='JNO7f'><b id='JNO7f'><form id='JNO7f'><ins id='JNO7f'></ins><ul id='JNO7f'></ul><sub id='JNO7f'></sub></form><legend id='JNO7f'></legend><bdo id='JNO7f'><pre id='JNO7f'><center id='JNO7f'></center></pre></bdo></b><th id='JNO7f'></th></span></q></dt></tr></i><div id='JNO7f'><tfoot id='JNO7f'></tfoot><dl id='JNO7f'><fieldset id='JNO7f'></fieldset></dl></div>