我是cakePHP的新手,我正在閱讀manuels併購買了這本書,我遇到過一個問題,需要一些幫助。mySQL在CakePHP加入查詢PHP
目前,我查詢我的DB這樣的(這是全班同學):
<?php
class TapplicantController extends AppController {
public function index() {
$this->set('page_title', 'Dashboard');
$tapplicant = $this->Tapplicant->query("SELECT tapplicant.AppID, tapplicant.AppIPAddress, tapplicant.AppAffID, tapplicant.AppDate, tapplicant.FirstName, tapplicant.LastName, tapplicant.Email, tapplicant.AppDomain, toutcome.AffCommission FROM tapplicant INNER JOIN toutcome ON tapplicant.AppID=toutcome.AppID LIMIT 0,15 ");
$this->set('tapplicant', $tapplicant);
}
}
,然後我喜歡這個顯示它和它的作品罰款:
<?php foreach ($tapplicant as $tapplicant) : ?>
<tr>
<td><?=$tapplicant['tapplicant']['AppID']; ?></td>
<td><?=$tapplicant['tapplicant']['AppAffID']; ?></td>
<td><?=$tapplicant['tapplicant']['FirstName']; ?></td>
<td><?=$tapplicant['tapplicant']['LastName']; ?></td>
<td><?=$tapplicant['tapplicant']['Email']; ?></td>
<td><?=$tapplicant['tapplicant']['AppDate']; ?></td>
<td><?=$tapplicant['tapplicant']['AppDomain']; ?></td>
<td><?=$tapplicant['tapplicant']['AffCommission']; ?></td>
</tr>
<?php endforeach; ?>
的問題是我有內部加入2表和它的不工作,我得到以下錯誤:未定義的索引:AffCommission
使用<?= $ tapplicant ['toutcome'] ['AffCommission']; ?> – Abhishek