Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To update a row, you don't use:</p> <pre><code>$myRow-&gt;update($data, $where); </code></pre> <p>You use:</p> <pre><code>$myRow-&gt;save(); </code></pre> <p>But trying to use <code>update()</code> on a row object should throw an exception.</p> <p>So I'm guessing you're actually calling the <code>update()</code> function on the <strong>table object</strong>, and not the <strong>row object</strong>. </p> <pre><code>$songs = new Songs(); //... $songs-&gt;update($data, $where); </code></pre> <p>At that point the row object is never even used, the query is simply generated from the <code>$data</code> array and the <code>$where</code> clause. </p> <p>If you want to use the custom <code>_update()</code> method you would need to do something like:</p> <pre><code>$songs = new Songs(); $song = $songs-&gt;find($id) //change some data $song-&gt;save(); </code></pre> <p>Of course is also perfectly valid to add custom logic at the table level, and should be noted while calling an update or insert from the table object does not use the row object, <strong>calling <code>save()</code> on the row object proxies the table object</strong>.</p> <p>For example, from the <code>Zend_Db_Table_Row</code> <code>_doInsert()</code> function:</p> <pre><code>$this-&gt;_insert(); //... $primaryKey = $this-&gt;_getTable()-&gt;insert($data); </code></pre> <p>So if you have custom logic that you want to use <em>every</em> time you update a row (whether you update from the table object or the row object), it should be put into the table object.</p> <p>From the <a href="http://framework.zend.com/manual/en/zend.db.table.row.html" rel="nofollow">Zend_Db_Table_Row docs</a>:</p> <blockquote> <p>If you need to do custom logic in a specific table, and the custom logic must occur for every operation on that table, it may make more sense to implement your custom code in the insert(), update() and delete() methods of your Table class. However, sometimes it may be necessary to do custom logic in the Row class.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload