English 中文(简体)
cakephp mysql 错误
原标题:cakephp mysql error

我对网站有些问题。 我希望这个视图能够显示所有与使用错误相关的发票( 在另一个表格中), 相反, 代码正在打印一个视图中的所有发票( 忽略用户 id ) 。 当查看 sql 语句时, cakephp debug 吐出它会显示空白的位置( 不要担心, 我将包含实际的 sql statment ) 。 我还创建了会话代码, 但我不确定如何编码它, 以便 Mysql 数据将显示使用错误 = 当前用户的位置 。

在此为视图的代码

<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
问题回答

看起来你没有在你的页面上传递一个ID。

/invoices/payinvoice/2

这可能是 url 的问题

试这个

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

将产生

<a href="/invoices/payinvoice/6">Invoice</a>




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签