サイトに問題があります。このビューで実行したいのは、(別のテーブルの) ユーザー ID に関連するすべての請求書を表示することです。代わりに、コードは 1 つのビューにすべての請求書を出力します (ユーザー ID を無視します)。Cakephp デバッグが吐き出す sql ステートメントを見ると、場所が空白として表示されます (実際の sql ステートメントを含めることを心配しないでください)。セッション コードも作成しましたが、mysql データが where userid = current user; と表示されるようにコーディングする方法がわかりません。
ここにビューのコードがあります
<table width="100%" border="1">
<table width="100%" border="1">
<tr>
<th>Biller</th>
<th>Subject</th>
<th>Date</th>
<th>Action</th>
</tr>
<?php foreach($invoices as $invoice):?>
<tr> debug($invoices);
<td align='center'><?php echo $this->Html->link($invoice['Invoice']['biller'],
array('action' => 'viewinvoice', $invoice['Invoice']['id'])); ;?> </td>
<td align='center'><?php echo $invoice['Invoice']['subject']; ?></td>
<td align='center'><?php echo $invoice['Invoice']['datecreated']; ?></td>
<td align='center'><a href="viewinvoice"><button>View Invoice</button></a><a href="disputeinvoice"><button>Dispute Invoice</button></a></td>
</tr>
<?php endforeach; ?>
</table>
これは、このビューに関連するクラスのコードです
public function payinvoice($id = null){
$this->set('title_for_layout', 'Pay Invoice');
$this->set('stylesheet_used', 'homestyle');
$this->set('image_used', 'eBOXLogoHome.jpg');
$this->layout='home_layout';
$this->set('invoices', $this->Invoice->find('all' , array('conditions' => array('Invoice.biller' => $id))));
}
ここに、サイトがデータを取得するために使用しているSQLコードがあります
SELECT `Invoice`.`id`, `Invoice`.`to`, `Invoice`.`biller`, `Invoice`.`subject`, `Invoice`.`description`, `Invoice`.`amount`, `Invoice`.`datecreated`, `Invoice`.`duedate` FROM `pra_cake`.`invoices` AS `Invoice` WHERE `Invoice`.`biller` IS NULL