Hallo! Selamat Datang di Marketplace produk digital, Freelancer terbaik di indonesia (69153 Members, 794 Products, 4715 Topic, 13113 Comments)

Migrasi dari database sqlite ke database mysql

Dibuat
Login Terakhir 18 Hari lalu,
Telah Dilihat 2088 Kali
Muh Dianatur Rahman Mengatakan : Sultan Account
  1. kira2 gmn yah perintahnya kalo pake db mysql
  2.  
  3. <?php
  4. class GrFingerService
  5. {
  6. // Constants declation
  7. public $GR_OK = 0;
  8. public $GR_MATCH = 1;
  9. public $GR_DEFAULT_CONTEXT = 0;
  10. public $GrFingerX;
  11. public $db;
  12.  
  13. // Application startup code
  14. public function initialize()
  15. {
  16. // Initialize GrFingerX Library
  17. $this->GrFingerX = new COM('GrFingerX.GrFingerXCtrl.1') or die ('Could not initialise object.');
  18. com_load_typelib('{A9995C7C-77BF-4E27-B581-A4B5BBD90E50}');
  19. // Open sqlite database
  20. if ($this->db = sqlite_open('GrFingerSample.db', 0666, $sqliteerror))
  21. {
  22. $query = sqlite_query($this->db, "SELECT name FROM sqlite_master WHERE type='table' and name='enroll'");
  23. $rows = sqlite_num_rows($query);
  24. if ($rows<1)
  25. sqlite_query($this->db, "CREATE TABLE enroll (id INTEGER PRIMARY KEY, tpt TEXT NOT NULL)");
  26. }
  27. else
  28. return false;
  29. if($this->GrFingerX->Initialize() != $this->GR_OK)
  30. return false;
  31. return true;
  32. }
  33.  
  34. // Application finalization code
  35. public function finalize()
  36. {
  37. sqlite_close ($this->db);
  38. $this->GrFingerX->Finalize();
  39. }
  40.  
  41. //Add a fingerprint to database
  42. public function enroll($tpt)
  43. {
  44. // Insert the template into database
  45. sqlite_query($this->db, "INSERT INTO enroll (tpt) VALUES ('".$tpt."')");
  46. //return sqlite_last_insert_rowid ($this->db);
  47. return sqlite_last_insert_rowid ($this->db);
  48. }
  49.  
  50. // Verify if two fingerprints match
  51. public function verify ($id,$rcvtpt)
  52. {
  53. // Find and encode the database template to base64
  54. $query = sqlite_query($this->db, "SELECT * FROM enroll WHERE id=".$id);
  55. $row = sqlite_fetch_array($query, SQLITE_ASSOC);
  56. $score = 0;
  57. // Comparing the given template and the encoded one
  58. $ret = $this->GrFingerX->VerifyBase64($rcvtpt,$row["tpt"],$score,$this->GR_DEFAULT_CONTEXT);
  59. if($ret == $this->GR_MATCH)
  60. return $row["id"];
  61. else
  62. return $ret;
  63. }
  64.  
  65. // Identify a fingerprint
  66. public function identify ($rcvtpt)
  67. {
  68. // Starting identification process
  69. $ret = $this->GrFingerX->IdentifyPrepareBase64($rcvtpt, $this->GR_DEFAULT_CONTEXT);
  70. if($ret!=$this->GR_OK)
  71. return $ret;
  72. // Getting enrolled templates from database
  73. $query = sqlite_query($this->db, "SELECT * FROM enroll");
  74. $score = 0;
  75. while ($row = sqlite_fetch_array($query, SQLITE_ASSOC))
  76. {
  77. // Comparing the current template and the given one
  78. $ret = $this->GrFingerX->IdentifyBase64($row["tpt"],$score,$this->GR_DEFAULT_CONTEXT);
  79. if( $ret == $this->GR_MATCH)
  80. return $row["id"];
  81. }
  82. return 0;
  83. }
  84. }
  85. ?>
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!

Online