mam ustawić skrzypce z tabel i danych hereHrabia jeśli użytkownik osiągnął limit borrwing
Próbuję napisać jeden sql, aby sprawdzić, czy użytkownik osiągnął limit kredytu dla każdej kategorii.
W tej chwili jest to wykonywane przy użyciu różnych instrukcji sql.
Ale sposób, w jaki idzie, jest prosty. Mem i id przechodzą przez kwerendę.
$medId = $_POST['memId']; Using 1 for this example. This is the members Id.
$id = $_POST['id']; Using 4 for this example. This is the item being lent.
Po tym zrobić:
select id, holder from collection_db where id = 4 // We have a valid item
select borrowMax from collection_db where id = (holder from the previous select) and category = 10 //Result = 2. Category indicates its a label and not a borrowable item.
select count(borrowedId) from lendings where memId = 1 and holder = (holder from the 1st query) //He's borrowed 2, under 1, so cant borrow any more. User 2 may borrow however.
if (count => borrowMax) {echo 'Cannot borrow more.';} else {echo 'Added to'}
Jak to może być połączone w jeden SQL lub jest to najlepiej pozostawić w ten sposób?
kogoś używając skrzypce :) – Woot4Moo
+1 na skrzypcach –