Skip to content

Instantly share code, notes, and snippets.

@JanVoracek
Created July 21, 2011 18:24
Show Gist options
  • Save JanVoracek/1097816 to your computer and use it in GitHub Desktop.
Save JanVoracek/1097816 to your computer and use it in GitHub Desktop.
Návrh zajištění unikátnosti rezervací pomocí unique indexu
$cetnost_tematu = 3; // vytáhne z db
$i = 0;
do {
mysql_query("INSERT INTO rezervace (id_tema,cetnost) VALUES ($tema,$i)");
$i++;
}while($i < $cetnost_tematu && mysql_errno() == 1062); // dokud nedosahnu maximalni cetnosti a insert selhal na unikatnosti zaznamu
PRIMARY | UNIQUE | ...
id | id_tema | cetnost | id_skupina |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment