-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
executable file
·42 lines (33 loc) · 1.49 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
notes
to solve invalid server index warning from phpmyadmin add $i = 1; to config.inc.php
to solve login error #2002 change
$cfg['Servers'][$i]['host'] = 'localhost';
to
$cfg['Servers'][$i]['host'] = '127.0.0.1';
print_r: prints variables in human readable format
to dump mysql schema:
mysqldump.exe -h 127.0.0.1 -u root -p --no-data flashcards > mysql/dbdump.sql
Passwords are stored as sha-256 hashes
mysql: SELECT SHA2('abc', 256);
php: hash("sha256", 'abc', false)
Starting the php server:
php -S localhost:8080
Useful queries:
Get all users, decks, and card counts. Showing orphaned decks and deckless users
OUTER JOIN must be emulated by UNIONing LEFT and RIGHT because MySQL:
SELECT user_name, deck_name, count(*)
FROM (
SELECT users.name AS user_name,decks.name AS deck_name,decks.deckid
FROM users LEFT JOIN decks ON users.id=decks.userid
UNION
SELECT users.name AS user_name,decks.name AS deck_name,decks.deckid
FROM users RIGHT JOIN decks ON users.id=decks.userid
) AS fulljoin
LEFT JOIN flashcards ON fulljoin.deckid=flashcards.deckid
GROUP BY fulljoin.deckid
Delete a user, their decks, and cards:
DELETE users,decks,flashcards
FROM users
JOIN decks on users.id=decks.userid
JOIN flashcards on decks.deckid=flashcards.deckid
WHERE users.id=4