我想得到计数invoice_Id是那些输入toady,我尝试查询但我什么都没有
这是我的SQL查询,我已经尝试了很多次但却什么都没有
select count(invoice_id)
from tbl_invoice
LEFT JOIN tbl_order
using(order_id)
WHERE tbl_invoice.invoice_date = '2017-10-18'
这是我在php中使用此查询的控制器
$this->global_model->_table_name = 'tbl_invoice';
$this->global_model->_order_by = 'invoice_id';
$today_order = $this->global_model->get_by(array("invoice_date"=>'$todaydate'), false);
//var_dump($todaydate,$today_order);die();
$_SESSION["today_order"] = $today_order;
这是我的观点文件
<?php
$today_order = $_SESSION["today_order"];
$today_order_count = count($today_order);
?>
<!------today order total count------->
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-credit-card"></i>
<span class="label label-danger"><?php if(!empty($today_order_count)){
echo $today_order_count;
}else{
echo '0';
}
?></span>
</a>
</li>
答案 0 :(得分:2)
您需要考虑到日期可能存储在datetime
WHERE tbl_invoice.invoice_date >= '2017-10-18'
AND tbl_invoice.invoice_date < '2017-10-19'
中。而且,这包含时间和日期。
尝试更改您的查询以涵盖整天:
DEFAULT Suffix == "@my", Strip-User-Name = No
User-Name := "%{User-Name}.domain.com"
DEFAULT User-Name !~ ".*@"
User-Name := "%{User-Name}@my.domain.com"
基本上,日期将存储为“2017-10-18 00:00:00”,或者带有其他时间戳。