【发布时间】:2009-10-20 04:11:09
【问题描述】:
(数据库结构如CakePHP select default value in SELECT input)
所以,我在 CakePHP 中有两个表:Trees 和 Leafs。每个 Leaf 对应的树都有一个 tree_id。每片叶子也有一个数字value。我为树烘焙的默认视图仅列出了表格中的所有树。有没有办法在该视图的表中添加一个动态列,对树的所有叶子进行求和并在表中显示总和,以及显示树的叶子数量的另一个字段?
示例:
Leafs
Id | Tree Id | Leaf value
-----+-----------+---------------
24 | 1 | 19
70 | 1 | 33
121 | 1 | 30
Trees
Id | Tree | Number of leafs | Sum of leafs | Actions
-----+--------+-------------------+----------------+-------------------
1 | foo | 120 | 7270 | View Edit Delete
2 | bar | 72 | 4028 | View Edit Delete
【问题讨论】:
标签: php sql mysql database cakephp