Query ringan mysql

Posted: December 5 ,2016 in Uncategorized

Mencari duplikasi data

 

SELECT payment_journal.`reference_no`
FROM payment_journal
INNER JOIN (SELECT reference_no
FROM payment_journal
GROUP BY payment_journal.`reference_no`
HAVING COUNT(id) > 1) dup
ON payment_journal.`reference_no` = dup.`reference_no`;


 

Fungsi untuk menghitung umur 

function age($date1, $date2) {
$diff = abs(strtotime($date2) - strtotime($date1));

$years = floor($diff / (365 * 60 * 60 * 24));
$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
$days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
//printf("%d Tahun, %d Bulan, %d Hari", $years, $months, $days);
printf("%d Tahun, %d Bulan", $years, $months);
}


Terbilang untuk penulisan kuitansi

function terbilang($x) {
    $x = abs($x);
    $angka = array("", "satu", "dua", "tiga", "empat", "lima",
    "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
    $temp = "";
    if ($x <12) {
        $temp = " ". $angka[$x];
    } else if ($x <20) {
        $temp = terbilang($x - 10). " belas";
    } else if ($x <100) {
        $temp = terbilang($x/10)." puluh". terbilang($x % 10);
    } else if ($x <200) {
        $temp = " seratus" . terbilang($x - 100);
    } else if ($x <1000) {
        $temp = terbilang($x/100) . " ratus" . terbilang($x % 100);
    } else if ($x <2000) {
        $temp = " seribu" . terbilang($x - 1000);
    } else if ($x <1000000) {
        $temp = terbilang($x/1000) . " ribu" . terbilang($x % 1000);
    } else if ($x <1000000000) {
        $temp = terbilang($x/1000000) . " juta" . terbilang($x % 1000000);
    } else if ($x <1000000000000) {
        $temp = terbilang($x/1000000000) . " milyar" . terbilang(fmod($x,1000000000));
    } else if ($x <1000000000000000) {
        $temp = terbilang($x/1000000000000) . " trilyun" . terbilang(fmod($x,1000000000000));
    }
    return $temp;
}


Untuk check email valid

public function is_valid_email($email){
 if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
 return true;
 }else{
 return false;
 }
 } 
 


Untuk check no telp hp

public function is_valid_cellphone($phone){
 /*
 * 
 telkomsel.regex = ^(\\+62|\\+0|0|62)8(1[123]|52|53|21|22|23)[0-9]{5,9}$ 
 simpati.regex = ^(\\+62|\\+0|0|62)8(1[123]|2[12])[0-9]{5,9}$
 as.regex = ^(\\+62|\\+0|0|62)8(52|53|23)[0-9]{5,9}$ 
 indosat.regex= ^(\\+62815|0815|62815|\\+0815|\\+62816|0816|62816|\\+0816|\\+62858|0858|62858|\\+0814|\\+62814|0814|62814|\\+0814)[0-9]{5,9}$
 im3.regex = ^(\\+62855|0855|62855|\\+0855|\\+62856|0856|62856|\\+0856|\\+62857|0857|62857|\\+0857)[0-9]{5,9}$
 xl.regex = ^(\\+62817|0817|62817|\\+0817|\\+62818|0818|62818|\\+0818|\\+62819|0819|62819|\\+0819|\\+62859|0859|62859|\\+0859|\\+0878|\\+62878|0878|62878|\\+0877|\\+62877|0877|62877)[0-9]{5,9}$ 
 smart.regex = ^(\\+62|\\+0|0|62)8(81|87)[0-9]{5,9}$
 fren.regex = ^(\\+62|\\+0|0|62)8(88|89)[0-9]{5,9}$
 tri.regex = ^(\\+62|\\+0|0|62)8(98|99)[0-9]{5,9}$
 BYRU.regex = ^(\\+62|\\+0|0|62)8(68)[0-9]{5,9}$
 
 */
 
 if (preg_match("/^(\\+62|\\+0|0|62)8(1[123]|52|53|21|22|23)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62|\\+0|0|62)8(1[123]|2[12])[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62|\\+0|0|62)8(52|53|23)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62815|0815|62815|\\+0815|\\+62816|0816|62816|\\+0816|\\+62858|0858|62858|\\+0814|\\+62814|0814|62814|\\+0814)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62855|0855|62855|\\+0855|\\+62856|0856|62856|\\+0856|\\+62857|0857|62857|\\+0857)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62817|0817|62817|\\+0817|\\+62818|0818|62818|\\+0818|\\+62819|0819|62819|\\+0819|\\+62859|0859|62859|\\+0859|\\+0878|\\+62878|0878|62878|\\+0877|\\+62877|0877|62877)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62|\\+0|0|62)8(81|87)[0-9]{5,9}$/", $phone)){
 return true;
 }else if (preg_match("/^(\\+62|\\+0|0|62)8(88|89)[0-9]{5,9}$/", $phone)){
 return true;
 }
 else if (preg_match("/^(\\+62|\\+0|0|62)8(98|99)[0-9]{5,9}$/", $phone)){
 return true;
 }
 else if (preg_match("/^(\\+62|\\+0|0|62)8(68)[0-9]{5,9}$/", $phone)){
 return true;
 }else{
 return false;
 }
 } 
 


Untuk check apakan komputer terkoneksi dengan internet

 function is_connected()
 {
 $connected = @fsockopen("www.google.com", 80); 
 //website, port (try 80 or 443)
 if ($connected){
 $is_conn = true; //action when connected
 fclose($connected);
 }else{
 $is_conn = false; //action in connection failure
 }
 return $is_conn;

 } 

Untuk Format Rupiah

    public function rupiahFormat($price) {
        return "Rp " . number_format($price, 2);
    }


 

Config Gammu 1.32 using windows 10, Mysql,ODBC

Posted: June 19 ,2016 in Uncategorized

I’m using odbc driver because gammu 1.33 smsdrc default config will always show errors

“Unknown Driver” and using odbc driver will solving this problem.

windows

Requirement :

  1. Gammu 1.32 download from http://wammu.eu/download/gammu/1.32.0/ for windows 64 bit
  2. apache friend xampp download from https://www.apachefriends.org/download.html
  3. Download mysql-connector-odbc-5.3.6-winx64.msi from http://dev.mysql.com/downloads/connector/odbc/

Ok Let’s to install the requirement above…

I will to explain the installation just using screen shoot :

xampp

 

Please double click your downloaded file mysql-connector-odbc-5.3.6-winx64.msi after finishing download to install this driver……

start-odbc.png

odbc-1

odbc-2odbc-3

odbc-4

odbc-5

odbc-6

odbc-7

odbc-8

ODBC MySQL installation was finished..then I will open my Gammu Configuration :

gammu-1

Before config let’s to see the port of our Modem port from device manager modem-1

Open gammurc file :

gammurc

smsdrc

cmd

 

Config is running…

gammu-2

smsdlog

 

2011 in review

Posted: August 26 ,2012 in Uncategorized
Tags: , ,

The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 9.900 times in 2011. If it were a concert at Sydney Opera House, it would take about 4 sold-out performances for that many people to see it.

Click here to see the complete report.