title: Update CGridView yii1 framework
body: <p>Having tried all possible options, but the relation does not want to work. But I get this error</p>
  
  <blockquote>
    <p>CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in order clause is ambiguous. The SQL statement executed was: SELECT <code>t</code>.<code>id</code> AS <code>t0_c0</code>, <code>t</code>.<code>user_id</code> AS <code>t0_c1</code>, <code>t</code>.<code>store_id</code> AS <code>t0_c2</code>, <code>t</code>.<code>status_id</code> AS <code>t0_c3</code>, <code>t</code>.<code>bill_to_id</code> AS <code>t0_c4</code>, <code>t</code>.<code>total</code> AS <code>t0_c5</code>, <code>t</code>.<code>new</code> AS <code>t0_c6</code>, <code>t</code>.<code>pay_method_id</code> AS <code>t0_c7</code>, <code>t</code>.<code>created</code> AS <code>t0_c8</code>, <code>t</code>.<code>updated</code> AS <code>t0_c9</code>, <code>t</code>.<code>billing_to_first</code> AS <code>t0_c10</code>, <code>t</code>.<code>billing_to_last</code> AS <code>t0_c11</code>, <code>t</code>.<code>billing_to_fax</code> AS <code>t0_c12</code>, <code>t</code>.<code>cc_last_four</code> AS <code>t0_c13</code>, <code>t</code>.<code>check_image_id</code> AS <code>t0_c14</code>, <code>t</code>.<code>comments</code> AS <code>t0_c15</code>, <code>t</code>.<code>warning_id</code> AS <code>t0_c16</code>, <code>t</code>.<code>artworkRec</code> AS <code>t0_c17</code>, <code>t</code>.<code>proofSent</code> AS <code>t0_c18</code>, <code>t</code>.<code>proofApprvd</code> AS <code>t0_c19</code>, <code>t</code>.<code>inHands</code> AS <code>t0_c20</code>, <code>orderItems</code>.<code>id</code> AS <code>t1_c0</code>, <code>orderItems</code>.<code>order_id</code> AS <code>t1_c1</code>, <code>orderItems</code>.<code>product_id</code> AS <code>t1_c2</code>, <code>orderItems</code>.<code>factory_id</code> AS <code>t1_c3</code>, <code>orderItems</code>.<code>qty</code> AS <code>t1_c4</code>, <code>orderItems</code>.<code>price</code> AS <code>t1_c5</code>, <code>orderItems</code>.<code>logo_name</code> AS <code>t1_c6</code>, <code>orderItems</code>.<code>po_number</code> AS <code>t1_c7</code>, <code>orderItems</code>.<code>art_id</code> AS <code>t1_c8</code>, <code>orderItems</code>.<code>art_status_id</code> AS <code>t1_c9</code>, <code>orderItems</code>.<code>send_proof</code> AS <code>t1_c10</code>, <code>orderItems</code>.<code>art_comments</code> AS <code>t1_c11</code>, <code>orderItems</code>.<code>rush_option_id</code> AS <code>t1_c12</code>, <code>orderItems</code>.<code>special_instructions</code> AS <code>t1_c13</code>, <code>orderItems</code>.<code>misc_charge_name</code> AS <code>t1_c14</code>, <code>orderItems</code>.<code>misc_charge_amount</code> AS <code>t1_c15</code> FROM <code>tbl_order</code> <code>t</code> LEFT OUTER JOIN <code>tbl_order_item</code> <code>orderItems</code> ON (<code>orderItems</code>.<code>order_id</code>=<code>t</code>.<code>id</code>) WHERE (orderItems.po_number=213) ORDER BY id DESC LIMIT 10</p>
  </blockquote>
  
  <p>I have a table.
  <a href="http://i.stack.imgur.com/1Te9v.png" rel="nofollow">enter image description here</a></p>
  
  <pre><code>public function relations()
  {
      // NOTE: you may need to adjust the relation name and the related
      // class name for the relations automatically generated below.
      return array(
          'invoices' =&gt; array(self::HAS_MANY, 'Invoice', 'order_id'),
          'billTo' =&gt; array(self::BELONGS_TO, 'Address', 'bill_to_id'),
          'checkImage' =&gt; array(self::BELONGS_TO, 'Files', 'check_image_id'),
          'payMethod' =&gt; array(self::BELONGS_TO, 'PayMethod', 'pay_method_id'),
          'status' =&gt; array(self::BELONGS_TO, 'Status', 'status_id'),
          'store' =&gt; array(self::BELONGS_TO, 'Websites', 'store_id'),
          'user' =&gt; array(self::BELONGS_TO, 'Users', 'user_id'),
          'warning' =&gt; array(self::BELONGS_TO, 'WarningsLog', 'warning_id'),
          'orderChangeLogs' =&gt; array(self::HAS_MANY, 'OrderChangeLog', 'order_id'),
          'orderItems' =&gt; array(self::HAS_MANY, 'OrderItem', 'order_id'),
          'shipments' =&gt; array(self::HAS_MANY, 'Shipment', 'order_id'),
          'warningsLogs' =&gt; array(self::HAS_MANY, 'WarningsLog', 'order_id'),
      );
  }
  
  
  
  
  public function search($array = null)
  {
  
  
      $criteria=new CDbCriteria;
  
      $criteria-&gt;compare('t.id',$this-&gt;id);
      $criteria-&gt;compare('user_id',$this-&gt;user_id);
      $criteria-&gt;compare('store_id',$this-&gt;store_id);
      $criteria-&gt;compare('status_id',$this-&gt;status_id);
      $criteria-&gt;compare('bill_to_id',$this-&gt;bill_to_id);
      $criteria-&gt;compare('total',$this-&gt;total,true);
      $criteria-&gt;compare('new',$this-&gt;new);
      $criteria-&gt;compare('pay_method_id',$this-&gt;pay_method_id);
      $criteria-&gt;compare('created',$this-&gt;created,true);
      $criteria-&gt;compare('updated',$this-&gt;updated,true);
      $criteria-&gt;compare('billing_to_first',$this-&gt;billing_to_first,true);
      $criteria-&gt;compare('billing_to_last',$this-&gt;billing_to_last,true);
      $criteria-&gt;compare('billing_to_fax',$this-&gt;billing_to_fax,true);
      $criteria-&gt;compare('cc_last_four',$this-&gt;cc_last_four);
      $criteria-&gt;compare('check_image_id',$this-&gt;check_image_id);
      $criteria-&gt;compare('comments',$this-&gt;comments,true);
      $criteria-&gt;compare('warning_id',$this-&gt;warning_id);
      $criteria-&gt;compare('artworkRec',$this-&gt;artworkRec,true);
      $criteria-&gt;compare('proofSent',$this-&gt;proofSent,true);
      $criteria-&gt;compare('proofApprvd',$this-&gt;proofApprvd,true);
      $criteria-&gt;compare('inHands',$this-&gt;inHands,true);
  
      $criteria-&gt;with = array('orderItems');
  
    //        $criteria-&gt;compare('orderItems.order_id', $this-&gt;id, true);
  
     $criteria-&gt;addCondition('orderItems.po_number=213');
  
      $criteria-&gt;together = true;
  
  
      return new CActiveDataProvider($this, array(
          'criteria'=&gt;$criteria,
          'sort'=&gt;array(
              'defaultOrder'=&gt;'id DESC',
          ),
      ));
  }
  </code></pre>
  
  <p>I would be glad of any help</p>