Advertisement
rakaerer

lib-php7.php

Apr 19th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. /**
  3. *lib-php7
  4. *
  5. * /Alternatif old mysql_ php7.0 support library mysqli_ extension/
  6. *
  7. * fitur :
  8. * dapata menggunakan syntax :
  9. * mysql_connect($host, $user, $pass)
  10. * mysql_select_db($db)
  11. * mysql_query($query)
  12. * mysql_fetch_row($result)
  13. * mysql_fetch_array($result)
  14. * mysql_fetch_assoc($result)
  15. * mysql_escape_string($string)
  16. * mysql_real_escape_string($string)
  17. * mysql_num_rows($result)
  18. * Cara pakai:
  19. * 1. Copy file lib-php7.php kedalam satu directory bersama file koneksi ex.(C:\xampp\htdocs\dirProjAnda\config\koneksi.php);
  20. * 2. Sisip kan file lib-php7.php kedalam file koneksi.php dengan menggunakan include atau require
  21. *
  22. *
  23. * ~Semoga Bermanfaat~
  24. * Contact : 9mail.raka@gmail.com
  25. **/
  26.  
  27. if(
  28. !function_exists("mysql_connect") &&
  29. !function_exists("mysql_select_db") &&
  30. !function_exists("mysql_query") &&
  31. !function_exists("mysql_fetch_row") &&
  32. !function_exists("mysql_fetch_array") &&
  33. !function_exists("mysql_fetch_assoc") &&
  34. !function_exists("mysql_escape_string") &&
  35. !function_exists("mysql_real_escape_string") &&
  36. !function_exists("mysql_num_rows"))
  37. {
  38. $_host = "";
  39. $_user = "";
  40. $_pass = "";
  41.  
  42. function mysql_connect($host, $user, $pass){
  43. global $_host, $_user, $_pass;
  44. $_host = $host;
  45. $_user = $user;
  46. $_pass = $pass;
  47. return TRUE;
  48. }
  49.  
  50. function mysql_select_db($db){
  51. global $conn, $_host, $_user, $_pass;
  52. $conn = new mysqli($_host, $_user, $_pass, $db);
  53. if($conn->connect_errno){
  54. die($conn->connect_error);
  55. }
  56. }
  57.  
  58. function mysql_query($query){
  59. global $conn;
  60. return mysql_query_connect($conn, $query);
  61. }
  62.  
  63. function mysql_query_connect($conn,$query){
  64. return $conn->query($query);
  65. }
  66. function mysql_fetch_row($result){
  67. return $result->fetch_row();
  68. }
  69.  
  70. function mysql_fetch_array($result){
  71. return $result->fetch_array();
  72. }
  73.  
  74. function mysql_fetch_assoc($result){
  75. return $result->fetch_assoc();
  76. }
  77.  
  78. function mysql_escape_string($string){
  79. $string = addslashes($string);
  80. $string = str_replace(array('%', '_'), array('\\%', '\\_'), $string);
  81. return $string;
  82. }
  83.  
  84. function mysql_real_escape_string($string){
  85. return mysql_escape_string($string);
  86. }
  87. function mysql_num_rows($result){
  88. return $result->num_rows;
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement