0

サイトに問題があります。このビューで実行したいのは、(別のテーブルの) ユーザー 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
4

2 に答える 2

1

これはおそらくURLの問題です

これを試して

<?php echo $this->Html->link('Invoice',
    array('controller' => 'invoices', 
          'action' => 'payinvoice', 
          $invoice['Invoice']['id'])
    );?>

それは生成します

<a href="/invoices/payinvoice/6">Invoice</a>
于 2012-05-23T17:10:36.390 に答える
1

ページに ID を渡していないようです。URL は次のようになります。

/invoices/payinvoice/2
于 2012-05-23T14:05:38.480 に答える