Guest User

penyimpanan_crud.php

a guest
Mar 7th, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. class crudpenyimpanan{
  3. private $mysqli;
  4. private $link;
  5. private $host = "localhost";
  6. private $user = "root";
  7. private $pass = "";
  8. private $selectDB = "inventory";
  9. private $id;
  10. private $nama;
  11.  
  12. function __costruct(){
  13. $this->connect();
  14. }
  15.  
  16. function connect(){
  17. $this->link = new mysqli($this->host,$this->user,$this->pass,$this->selectDB);
  18. if (!$this->link) {
  19. // jika variabel link gagal / ada kesalahan. maka,
  20. $this->error = "Connection Fail".$this->link->connect_error;
  21. return false;
  22. }
  23. }
  24.  
  25. function insert($id,$nama){
  26. $insert_row = $this->link->query("INSERT INTO t_lokasi VALUES ('$id','$nama')");
  27. if ($insert_row) {
  28. echo "sukses";
  29. }else{
  30. die("Error (".$this->link->errno.") ").$this->link->error;
  31. }
  32. }
  33. }
  34. ?>
Add Comment
Please, Sign In to add comment