Does select exists still work?
- Code: Select all
function uniquedoesexist($dbHandle,$tablename,$fieldname,$value) {
$sql = 'SELECT EXISTS(SELECT * FROM `'.$tablename.'` WHERE `'.$fieldname.'` = ? LIMIT 1)';
$stmt = mysqli_prepare($dbHandle, $sql);
mysqli_stmt_bind_param($stmt, 's',$value);
$sqlResult = mysqli_stmt_execute($stmt);
echo '$sqlResult: ' . $sqlResult.$br;
return $sqlResult;
}
With username Index varchar(255) utf8_german2_ci
[1]: https://stackoverflow.com/questions/1676551/best-way-to-test-if-a-row-exists-in-a-mysql-table/10688065#10688065
Sorry for my beginner question.
The fieldname is set to unique.
Side note:
All the answers the stackoverflow system suggests DO NOT answer the question, but rather suggest using to check the number of returned rows, instead of using exists at all. Also the given links over there for explanations actually do not lead to webpages that do explain what the exists-result does represent.