$exp_time = time() - (3600 * $set['jam_pembayaran']);
$q=$pdo->query("SELECT * FROM transaksi WHERE (tr_pembayaran ='bank_bca' OR tr_pembayaran ='bank_mandiri' OR tr_pembayaran ='bank_bni' OR tr_pembayaran ='bank_bri') AND (tr_status_pembayaran='pending') AND (tr_tanggal > '$exp_time')");
if ($q->rowCount()){
foreach($q->fetchAll() as $trx){
@file_get_contents(site_url('/payment/'.$trx->tr_pembayaran.'/id/'.$trx->tr_id));}}
答案 0 :(得分:0)
在codeigniter
中尝试以下查询。您必须使用查询分组才能正确输出。
$query = $this->db->select('*')->from('transaksi')
->group_start()
->where('tr_pembayaran', 'bank_bca')
->or_where('tr_pembayaran','bank_mandiri')
->or_where('tr_pembayaran','bank_bni')
->or_where('tr_pembayaran','bank_bri')
->group_end()
->where('tr_status_pembayaran', 'pending')
->where('tr_tanggal >', $exp_time)
->get();
if ($query->num_rows() > 0){
$res = $query->result();
foreach($res as $trx){
@file_get_contents(site_url('/payment/'.$trx->tr_pembayaran.'/id/'.$trx->tr_id));
}
}
有关详情,请参阅此处https://www.codeigniter.com/userguide3/database/query_builder.html#query-grouping
答案 1 :(得分:0)
Codeignitor代码。 在你的模型中写一个函数
$exp_time = time() - (3600 * $set['jam_pembayaran']);
$this->db->select('*');
$this->db->from('transaksi');
$this->db->where('tr_pembayaran' ,'bank_bca');
$this->db->or_where('tr_pembayaran' ,'bank_mandiri');
$this->db->or_where('tr_pembayaran' ,'bank_bni');
$this->db->or_where('tr_pembayaran' ,'bank_bri');
$this->db->where('(tr_status_pembayaran' ,'pending');
$this->db->where('tr_tanggal > ','$exp_time)');
$query = $this->db->get();
if ($query->num_rows()){
foreach($query->result() as $r){
@file_get_contents(site_url('/payment/'.$r->tr_pembayaran.'/id/'.$r- >tr_id));}}