<small id='xCnX4'></small><noframes id='xCnX4'>

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

  2. <tfoot id='xCnX4'></tfoot>

  3. <legend id='xCnX4'><style id='xCnX4'><dir id='xCnX4'><q id='xCnX4'></q></dir></style></legend>
      <bdo id='xCnX4'></bdo><ul id='xCnX4'></ul>

      带连接的 Codeigniter 活动记录更新

      时间:2024-08-22
      <i id='VdixX'><tr id='VdixX'><dt id='VdixX'><q id='VdixX'><span id='VdixX'><b id='VdixX'><form id='VdixX'><ins id='VdixX'></ins><ul id='VdixX'></ul><sub id='VdixX'></sub></form><legend id='VdixX'></legend><bdo id='VdixX'><pre id='VdixX'><center id='VdixX'></center></pre></bdo></b><th id='VdixX'></th></span></q></dt></tr></i><div id='VdixX'><tfoot id='VdixX'></tfoot><dl id='VdixX'><fieldset id='VdixX'></fieldset></dl></div>

            <tbody id='VdixX'></tbody>

              <bdo id='VdixX'></bdo><ul id='VdixX'></ul>

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

              1. 本文介绍了带连接的 Codeigniter 活动记录更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两张桌子:

                table1:id、user_id、poll_id、options_id

                table2: id, poll_id, votes

                column votes 是一个整数,我想通过使用一些 where 子句加入表来更改值:

                $this->db->set('votes', 'votes - 1', FALSE)->join('table1', 'poll_votes.options_id = table2.id')->where('poll_id', $row)->where('user_id', $id)->更新('table2');

                我收到此错误:

                <上一页>错误号:1054'where 子句'中的未知列'user_id'更新 `table2` SET votes = votes - 1 WHERE `poll_id` = '9' AND `user_id` = '1'

                解决方案

                试试这个:

                $this->db->set('votes', 'votes - 1', FALSE)$this->db->where('table1.user_id',$id);$this->db->where('table2.poll_id',$row);$this->db->update('table1 join table2 ON table1.poll_id=table2.poll_id');

                i have two tables:

                table1: id, user_id, poll_id, options_id

                table2: id, poll_id, votes

                column votes is an integer and i want to change the value by joining the tables with some where clauses:

                $this->db
                ->set('votes', 'votes - 1', FALSE)
                ->join('table1', 'poll_votes.options_id = table2.id')
                ->where('poll_id', $row)
                ->where('user_id', $id)
                ->update('table2');
                

                Im getting this error:

                Error Number: 1054
                Unknown column 'user_id' in 'where clause'
                UPDATE `table2` SET votes = votes - 1 WHERE `poll_id` = '9' AND `user_id` = '1'
                

                解决方案

                Try this one:

                $this->db->set('votes', 'votes - 1', FALSE)
                $this->db->where('table1.user_id',$id);
                $this->db->where('table2.poll_id',$row);
                $this->db->update('table1 join table2 ON table1.poll_id= table2.poll_id');
                

                这篇关于带连接的 Codeigniter 活动记录更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 Codeigniter 中更新多行 下一篇:编写 PHP SQL 更新语句的最佳方法

                相关文章

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

                  <tfoot id='gLCiB'></tfoot>

                  <small id='gLCiB'></small><noframes id='gLCiB'>

                1. <legend id='gLCiB'><style id='gLCiB'><dir id='gLCiB'><q id='gLCiB'></q></dir></style></legend>