我有这样的观点:
我想要的是当我点击按钮时,它会执行一个选择查询:
SELECT discounts.product_id, products.product_name,
sum(products.product_price - discounts.product_discount) as total_Amount,
count(orders.order_id) as total_Number
FROM products
inner join discounts on products.product_id = discounts.product_id
inner join orders on discounts.discount_id = orders.discount_id
where discounts.start_time >= **FromTextBox** and discounts.end_time <= **ToTextBox**
group by discounts.product_id,products.product_name
FromTextBox和ToTextBox是来自2个文本框的值。
这是在我的控制器中:
....
$option['fields']= array('Discount.product_id','Product.product_name','benefit','number');
//$option['conditions']=array('Discount.start_time >'=>array('')); //where I put values from view
$option['group'] = array('Discount.product_id','Product.product_name');
$products = $this->Order->find('all',$option);
$this->set('products',$products);
我的观点:
<label class="control-label">From</label>
<div class="controls input-append date" id="dp1" data-date="" data-date-format="dd MM yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
<input size="16" type="text" value="" readonly> <-- where I put textbox
<span class="add-on"><i class="icon-remove"></i></span>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<label class="control-label">To</label>
<div class="controls input-append date" id="dp2" data-date="" data-date-format="dd MM yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
<input size="16" type="text" value="" readonly> <-- where I put textbox
<span class="add-on"><i class="icon-remove"></i></span>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div>
<?php echo $this->Form->button('A Button'); ?>
</div>
两个文本框用于Bootstrap datepicker。 请帮我!提前谢谢。
答案 0 :(得分:2)
您应该使用“Ajax”将“datepicker”中选择的内容发送到服务器,执行查询并使用结果创建表。 cakephp中没有针对您的问题的直接方法