Reputation: 81
How can I use my prepared statement to retrieve the enum value of a specific user as a string and check it against another string in php?
Upvotes: 0
Views: 85
Reputation: 196
If you are using PDO, you can do a select statement and check it against the string.
$conn = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$query = $conn->prepare("SELECT `what` FROM `users` WHERE `user_id` = ?");
$query->bindValue(1, $user_id);
try {
$query->execute();
} catch (PDOException $e) {
die($e->getMessage());
}
$dbValue = $query->fetchColumn();
if ($dbValue === 'string') {
echo 'the db value does match the string.';
} else {
echo 'the db value is not equal to the string.';
}
Upvotes: 1