Read 230 times | Created 2013-06-30 15:19:59 | Updated 2013-06-30 15:19:59 | | |

 

<?php
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$dbname='gammu';
$db=new mysqli($dbhost,$dbuser,$dbpass,$dbname);
$sql= <<<QUERY
INSERT INTO 
  outbox (
    InsertIntoDB,
    SendingDateTime,
    DestinationNumber,
    TextDecoded,
    SendingTimeOut,
    DeliveryReport,
    CreatorID
  )
SELECT 
  SYSDATE(),
  SYSDATE,
  n.hp,
  'tanggal jatuh tempo pinjaman anda tinggal 2 hari lagi',
  SYSDATE(),
  'yes',
  'system'
FROM 
  pinjaman p
  LEFT JOIN nasabah n USING(no_nasabah)
WHERE 
  DATE_SUB(DATE_ADD(p.tanggal_pinjam,INTERVAL 1 MONTH), INTERVAL 2 DAY)=CURRENT_DATE;
QUERY;
$db->query($sql);
$db->close();
?>