Kisi-kisi Soal UTS dan UAS Elektronika Beserta Jawaban

SOAL A 1) Berikut ini yang termasuk komponen elektronika dengan jenis komponen pasif yaitu ....

Kisi-kisi Soal UTS dan UAS Sistem Terdistribusi Beserta Jawaban

SOAL A 1. Berikut ini yang merupakan karakteristik dari definisi sistem terdistribusi adalah ....

Remove Bios Password and Harddissk (HDD) Laptop

I think to remove the bios password on an average PC is already can, although without having to memorize the password. the system jumpers or removing battery bios. ever see a supervisor, admin, system, HDD, bios, setup password?

Memperbaiki Kick Starter Motor Matic

Motor Matic is a motor that is the easiest to use and most in our homeland. please note that the motor also takes care of very sensitive, just like a computer that also takes care of sensitive anyway.

Gejala Kerusakan Mesin Air Submersible Metabo

Mesin Air Submersible atau yang sering disebut kebanyakan orang (satelit) ini sangat bagus, dengan sistemnya yang canggih dan fleksible. tipe mesin yang berbasis kerja di dalam tanah dan hanya menggunakan satu pipa ini, sangat berguna untuk anda yang memiliki banyak lumpur atau air kuning setelah pengeboran.

Showing posts with label CodeIgneter. Show all posts
Showing posts with label CodeIgneter. Show all posts

02 February 2020

How to fix base url in framework

We can set the base url or url in our framework to be automatically without change it wherever you want to place it in htdocs or localhost.

In CodeIgneter we will set it in application/config/config.php

Place this

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url']    = "$root";

//$config[base_url] = "http://localhost/";

In Laravel we will set it in config/app.php

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
return [
    'debug' => env('APP_DEBUG', false),
    //'url' => 'http://localhost',
      'url' => $root,
.......


So this is easy to fix all problem in your drive/ PC and your hosting wherever you want.

Share:

How To Make String, Char, Varchar To be Auto Increment in MySQL with PHP

Making varchar or string or char to be automatically add as auto increment, is't impossible?

Yah inilah yang dicari-cari selama ini jika anda ingin menambahkan atau membuat primary key dalam table dari tipe data char/ varchar/ string lalu ingin menjadikannya otomatis layaknya auto increment, berikut ini adalah salah satu contoh jika anda membuat primary key secara otomatis menambahkan kode sesuai dengan keinginan kita atau sering disebut dengan custom.

Kita asumsikan membuat ini dengan Framework dengan memiliki 1 tabel dengan format berikut:

CREATE TABLE `tb_supplier` (
  `id_supplier` char(5) NOT NULL,
  `nm_supplier` varchar(20) DEFAULT NULL,
  `no_hp` varchar(12) DEFAULT NULL,
  `email` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id_supplier`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records of tb_supplier
-- ----------------------------
INSERT INTO `tb_supplier` VALUES ('S0001', 'Supervisor', '1238123', 'email@gmail.com');
INSERT INTO `tb_supplier` VALUES ('S0002', 'minyak', '08998600083', 'justpoypoy@gmail.com');




kemudian buatlah sebuah class dalam Models seperti ini

function kodebaru() {
        $q = $this->db->query("SELECT id_supplier, substr(id_supplier, 2, 4) as id_baru FROM tb_supplier ORDER BY id_supplier DESC LIMIT 1") -> row();
        if(!empty($q)){
            $f = str_replace($q->id_supplier, 'S', '5.'.$q->id_baru);
            $b = (float)$f+0.0001;
            if(strlen(utf8_decode($b))==6){
                $k = substr($b,2,4);
            }else if(strlen(utf8_decode($b))==5){
                $t = str_replace($b, $b, $b.'0');
                $k = substr($t,2,4);
            }else if(strlen(utf8_decode($b))==4){
                $t = str_replace($b, $b, $b.'00');
                $k = substr($t,2,4);
            }else if(strlen(utf8_decode($b))==3){
                $t = str_replace($b, $b, $b.'000');
                $k = substr($t,2,4);
            }else{
                $k = 'err';
            }
         
            $kb = 'S'.$k;
        }else{
            $kb = 'S0001';
        }
        return $kb;
        }



Setelah itu masukkan dalam Controllers

          $this->data['row']   = $this -> M_supplier -> kodebaru();
          $this -> load -> view('your template',$this -> data);


Yang paling terakhir masukkan dalam Views untuk form tambah atau Add seperti ini


               
               



Dan hasilnya pasti akan sesuai dengan format yang ada, alasan kenapa menggunakan float yaitu titik beratnya pada banyaknya nol yang harus selalu ada. jika dirubah dengan integer maka nol tersebut akan hilang, kemudian ada rules tambahan yang membuatnya sempurna.
Semoga dapat bermanfaat.

Call us to make it's easy for making web. Thank you
Share:

Blog Archive