所以这是我最新的问题:我在我的 Cakephp 控制器中运行这个查询:
$acctRenewLast2Entries = $this->AccountRenew->find
(
'all',
array
(
'conditions' => array('Acc_Id' => $plan["Account"]["Acc_Id"]),
'order' => array('AccR_Id' => 'DESC')
)
);
我期待这条 SQL 语句有 4 条记录。相反,在我的控制器中运行调试时,这是我为上面的每一行得到的(见第一条记录):
app/controllers/admins_controller.php (line 2584)
1
app/controllers/admins_controller.php (line 2584)
Array
(
[AccountRenew] => Array
(
[AccR_Id] => 470
[AccR_Date] => 2012-06-23 01:21:11
[AccR_Hstart_Date] => 2012-06-23 01:21:11
[AccR_Hend_Date] => 2012-08-23 01:21:11
[AccR_End_Date] => 2013-08-23 01:21:11
[AccR_Status] => PAID
[AccR_Reason] => RENEWAL
[Inv_Id] => 467
[Inac_Id] =>
[Acc_Id] => 196
[AccT_Id] => 44
[Amount] => 16
[AccP_Id] => 0
)
)
app/controllers/admins_controller.php (line 2584)
Array
(
[AccountRenew] => Array
(
[AccR_Id] => 465
[AccR_Date] => 2012-06-23 01:17:35
[AccR_Hstart_Date] => 2012-06-23 01:17:35
[AccR_Hend_Date] => 2012-07-23 01:17:35
[AccR_End_Date] => 2012-07-23 01:17:35
[AccR_Status] => PAID
[AccR_Reason] => RENEWAL
[Inv_Id] => 462
[Inac_Id] =>
[Acc_Id] => 196
[AccT_Id] => 41
[Amount] => 16
[AccP_Id] => 0
)
)
app/controllers/admins_controller.php (line 2584)
Array
(
[AccountRenew] => Array
(
[AccR_Id] => 269
[AccR_Date] => 2012-06-06 10:15:56
[AccR_Hstart_Date] => 2012-06-06 17:15:56
[AccR_Hend_Date] => 2012-06-20 17:15:56
[AccR_End_Date] => 2012-06-20 10:15:56
[AccR_Status] => TRIAL
[AccR_Reason] =>
[Inv_Id] => 0
[Inac_Id] =>
[Acc_Id] => 196
[AccT_Id] => 0
[Amount] => 0
[AccP_Id] => 0
)
)
现在,当我运行 sql_dump 时,我得到以下运行的查询:
SELECT `AccountRenew`.`AccR_Id`, `AccountRenew`.`AccR_Date`, `AccountRenew`.`AccR_Hstart_Date`, `AccountRenew`.`AccR_Hend_Date`, `AccountRenew`.`AccR_End_Date`, `AccountRenew`.`AccR_Status`, `AccountRenew`.`AccR_Reason`, `AccountRenew`.`Inv_Id`, `AccountRenew`.`Inac_Id`, `AccountRenew`.`Acc_Id`, `AccountRenew`.`AccT_Id`, `AccountRenew`.`Amount`, `AccountRenew`.`AccP_Id` FROM `account_renews` AS `AccountRenew` WHERE `Acc_Id` = 196 ORDER BY `AccR_Id` DESC 4 4
当我在 MySQL 中运行上述查询时,我确实得到了所有 4 条记录,包括数组中显示为 1 的第一条记录(在我的文章顶部)。
我真诚地希望有人可以提供帮助,因为我在过去的 1.5 天里没有任何运气来解释为什么 MySQL 会提取完整的集合,但 Cake 似乎只检索最后 3 个,并将第一条记录替换为“1”的数组”。
提前致谢!