Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- SET NAMES utf8mb4;
- CREATE TABLE `copy_pw_values` (
- `val_id` smallint unsigned NOT NULL AUTO_INCREMENT,
- `val_type` tinyint unsigned NOT NULL,
- `val_hash` bigint unsigned NOT NULL,
- PRIMARY KEY (`val_id`),
- UNIQUE KEY `val_hash` (`val_hash`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
- INSERT INTO `copy_pw_values` (`val_id`, `val_type`, `val_hash`) VALUES
- (1033, 3, 13326067295508650029),
- (1736, 3, 8969302881072144);
- */
- $connection = new \mysqli(...);
- $statement1 = $connection->prepare('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=? AND `val_hash`=?');
- $type1 = 3;
- $hash1 = '8969302881072144';
- $statement1->bind_param('is', $type1, $hash1);
- $statement1->execute();
- echo $statement1->get_result()->num_rows;
- $type2 = '3';
- $hash2 = '8969302881072144';
- $statement1->bind_param('ss', $type2, $hash2);
- $statement1->execute();
- echo $statement1->get_result()->num_rows;
- $type3 = 3;
- $hash3 = '13326067295508650029';
- $statement1->bind_param('is', $type3, $hash3);
- $statement1->execute();
- echo $statement1->get_result()->num_rows;
- // Returns 0, should return 1.
- $type4 = '3';
- $hash4 = '13326067295508650029';
- $statement1->bind_param('ss', $type4, $hash4);
- $statement1->execute();
- echo $statement1->get_result()->num_rows;
- // Returns 0, should return 1.
- echo "\n";
- $statement2 = $connection->prepare('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_hash`=?');
- $hash5 = '8969302881072144';
- $statement2->bind_param('s', $hash5);
- $statement2->execute();
- echo $statement2->get_result()->num_rows;
- $hash6 = '13326067295508650029';
- $statement2->bind_param('s', $hash6);
- $statement2->execute();
- echo $statement2->get_result()->num_rows;
- echo "\n";
- echo $connection->query('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=3 AND `val_hash`=\'8969302881072144\'')->num_rows;
- echo $connection->query('SELECT `val_id`, `val_type` FROM `copy_pw_values` WHERE `val_type`=3 AND `val_hash`=\'13326067295508650029\'')->num_rows;
- echo "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement