Skip to content

Instantly share code, notes, and snippets.

@avinashseth
Created July 4, 2016 09:47
Show Gist options
  • Save avinashseth/a185bd2f1e9dc2a6b5c029dcd8f7f6e8 to your computer and use it in GitHub Desktop.
Save avinashseth/a185bd2f1e9dc2a6b5c029dcd8f7f6e8 to your computer and use it in GitHub Desktop.
<?php
function is_unique
(
$db = null
)
{
// this statement means please count, and tell me how many students have rollnumber = 1022
$count = $db->count("students",["student_rollnumber"=>"1022"]);
// if count == 0 means no student has rollnumber 1022
if($count == 0) {
return true; // yes it is unique
} else {
// else means there is 1 or more student who have rollnumber 1022 which means it is not unique
return false; // no it is not unique
}
}
// using library medoo for mysql
// website http://medoo.in/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment