如何显示前几个月的开始和结束日期?

时间:2019-05-17 02:48:23

标签: vue.js pdo

我在tbl_transaction表中有transaction_date。我想显示客户的所有交易取决于日期开始和日期结束。我检查它是否正常工作,并搜索该月之前的上个月,但是我得到了一个空表,其中没有定义的名字和姓氏,您可以看到下面的图片。如果我的表中只有一个transaction_date,该怎么办?

 public function searchEndAndStartDate() {
     $date_start = date('Y-m-d', strtotime($transaction_date));
     $date_end = date('Y-m-d', strtotime($transaction_date));

    $sql = "SELECT tbl_transaction_details.details_id, 
 tbl_medicine.medicine_name, tbl_transaction_details.quantity, 
 tbl_transaction_details.price, tbl_transaction.transaction_date, 
 tbl_transaction_details.total_price, tbl_user.first_name, 
 tbl_user.last_name FROM tbl_transaction_details INNER JOIN 
 tbl_transaction ON tbl_transaction_details.transaction_id = 
 tbl_transaction.transaction_id INNER JOIN tbl_user ON 
 tbl_transaction.user_id = tbl_user.user_id INNER JOIN tbl_medicine ON 
 tbl_transaction_details.medicine_id = tbl_medicine.medicine_id WHERE 
 transaction_id > :transaction_id AND transaction_date 
 BETWEEN :date_start AND :date_end";

    $stmt = $this->connection->prepare($sql);
    $stmt->execute([
        ":date_start" => $date_start,
        ":date_end" => $date_end
    ]);
    return $stmt->fetchAll();
}

Vue JS方法

 searchEndAndStartDate : function() {
    axios({
        method : "GET",
        url : this.urlRoot + "gulod/search_date.php?keyword=",
        params : {
            keyword : this.start_date,
            keyword : this.end_date
        }
    }).then(function (response){
        vm.gulod_transaction_details = response.data;
        console.log(response);
    });
},

0 个答案:

没有答案