Guest User

Untitled

a guest
Jan 21st, 2021
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. SET NAMES utf8mb4;
  4.  
  5. CREATE TABLE `copy_pw_values` (
  6.   `val_id` smallint unsigned NOT NULL AUTO_INCREMENT,
  7.   `val_type` tinyint unsigned NOT NULL,
  8.   `val_hash` bigint unsigned NOT NULL,
  9.   PRIMARY KEY (`val_id`),
  10.   UNIQUE KEY `val_hash` (`val_hash`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  12.  
  13. INSERT INTO `copy_pw_values` (`val_id`, `val_type`, `val_hash`) VALUES
  14. (1033,  3,  13326067295508650029),
  15. (1736,  3,  8969302881072144);
  16. */
  17.  
  18. $connection = new \mysqli(...);
  19.  
  20. $statement1 = $connection->prepare('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=? AND `val_hash`=?');
  21.  
  22. $type1 = 3;
  23. $hash1 = '8969302881072144';
  24. $statement1->bind_param('is', $type1, $hash1);
  25. $statement1->execute();
  26. echo $statement1->get_result()->num_rows;
  27.  
  28. $type2 = '3';
  29. $hash2 = '8969302881072144';
  30. $statement1->bind_param('ss', $type2, $hash2);
  31. $statement1->execute();
  32. echo $statement1->get_result()->num_rows;
  33.  
  34. $type3 = 3;
  35. $hash3 = '13326067295508650029';
  36. $statement1->bind_param('is', $type3, $hash3);
  37. $statement1->execute();
  38. echo $statement1->get_result()->num_rows;
  39. // Returns 0, should return 1.
  40.  
  41. $type4 = '3';
  42. $hash4 = '13326067295508650029';
  43. $statement1->bind_param('ss', $type4, $hash4);
  44. $statement1->execute();
  45. echo $statement1->get_result()->num_rows;
  46. // Returns 0, should return 1.
  47.  
  48. echo "\n";
  49.  
  50. $statement2 = $connection->prepare('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_hash`=?');
  51.  
  52. $hash5 = '8969302881072144';
  53. $statement2->bind_param('s', $hash5);
  54. $statement2->execute();
  55. echo $statement2->get_result()->num_rows;
  56.  
  57. $hash6 = '13326067295508650029';
  58. $statement2->bind_param('s', $hash6);
  59. $statement2->execute();
  60. echo $statement2->get_result()->num_rows;
  61.  
  62. echo "\n";
  63.  
  64. echo $connection->query('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=3 AND `val_hash`=\'8969302881072144\'')->num_rows;
  65. echo $connection->query('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=3 AND `val_hash`=\'13326067295508650029\'')->num_rows;
  66.  
  67. echo "\n";
  68.  
RAW Paste Data