title: Codeigniter: Query UPDATE in PHP create new row instead update
body: <p>I'm using codeigniter, and I'm trying to UPDATE the database, but instead it always creates a new row and doesn't update the existing one.</p>
  <p>I ask for your help because I can't understand where the problem is, the query in heidisql works without problems.</p>
  <p>Controller:</p>
  <pre><code>public function editClientSubmit()
  {
      $params = [
          'id_client' =&gt; $this-&gt;request-&gt;getPost('id_client'),
          'code' =&gt; $this-&gt;request-&gt;getPost('code'),
          'name' =&gt; $this-&gt;request-&gt;getPost('name'),
          'nif' =&gt; $this-&gt;request-&gt;getPost('nif'),
          'address' =&gt; $this-&gt;request-&gt;getPost('address'),
          'postal_code_1' =&gt; $this-&gt;request-&gt;getPost('postal_code_1'),
          'postal_code_2' =&gt; $this-&gt;request-&gt;getPost('postal_code_2'),
          'city' =&gt; $this-&gt;request-&gt;getPost('city'),
      ];
  
      $db = db_connect();
      $db-&gt;query(
          &quot;UPDATE clients
          SET code = :code:, name = :name:, nif = :nif:, address = :address:,
          postal_code_1 = :postal_code_1:, postal_code_2 = :postal_code_2:, city = :city:
          WHERE id_client = :id_client:&quot;,
          $params
      );
      $db-&gt;close();
  }
  </code></pre>
  <p>View:</p>
  <pre><code> &lt;?php
          helper(&quot;form&quot;);
          echo form_open('main/editclientsubmit');
          ?&gt;
          &lt;input type=&quot;text&quot; name=&quot;id_client&quot; value=&quot;&lt;?= $client-&gt;id_client ?&gt;&quot;&gt;
          &lt;div class=&quot;form-group&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;code&quot; placeholder=&quot;Código&quot; value=&quot;&lt;?= $client-&gt;code ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;name&quot; placeholder=&quot;Nome&quot; value=&quot;&lt;?= $client-&gt;name ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;nif&quot; placeholder=&quot;NIF&quot; value=&quot;&lt;?= $client-&gt;nif ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;address&quot; placeholder=&quot;Morada&quot; value=&quot;&lt;?= $client-&gt;address ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;postal_code_1&quot; placeholder=&quot;Código Postal&quot; value=&quot;&lt;?= $client-&gt;postal_code_1 ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;postal_code_2&quot; placeholder=&quot;Código Postal 2&quot; value=&quot;&lt;?= $client-&gt;postal_code_2 ?&gt;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;city&quot; placeholder=&quot;Cidade&quot; value=&quot;&lt;?= $client-&gt;city ?&gt;&quot;&gt;
          &lt;/div&gt;
          &lt;input type=&quot;submit&quot; value=&quot;Actualizar&quot;&gt;
  
          &lt;?=
          form_close();
          ?&gt;
  </code></pre>