Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP : Send Value To Model Function
    primarykey
    data
    text
    <p>My idea like this. I create a function at Model like this.</p> <pre><code>public function status($id = null) { $conditions = array('Transaction.catalogue_id' =&gt; $id); $status = $this-&gt;find('first',array('conditions' =&gt; $conditions, 'fields' =&gt; array('Transaction.status'),'order' =&gt; array('Transaction.id' =&gt; 'desc')) ); return $status['Transaction']['status']; } </code></pre> <p>How i send the value of $id from this loop?</p> <pre><code>&lt;table cellspacing="0" cellpadding="0" border="0" class="all"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;No&lt;/th&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Author&lt;/th&gt; &lt;th&gt;ISBN&lt;/th&gt; &lt;th&gt;Location&lt;/th&gt; &lt;th&gt;Availability&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;?php $count = 1;?&gt; &lt;tbody&gt; &lt;?php foreach ($Catalogue as $Catalogue): ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $count++; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;Html-&gt;link($Catalogue['Catalogue']['title'],array('controller' =&gt; 'transactions', 'action' =&gt; 'view',$Catalogue['Catalogue']['id']),array('escape' =&gt; false, 'class' =&gt; 'ajax')); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Catalogue['Catalogue']['author']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Catalogue['Catalogue']['isbn']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Catalogue['Location']['rack']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;getstatus($Catalogue['Catalogue']['id'])&lt;/td&gt; &lt;/tr&gt; &lt;?php endforeach; ?&gt; &lt;/tbody&gt; &lt;?php unset($Catalogue); ?&gt; &lt;/table&gt; </code></pre> <p>Can we do $this->getstatus($Catalogue['Catalogue']['id'])?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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