imooc Restful API
Tools
- MAMP
- MySQLWorkBench
- Restlet client
SQL Script by MySQLWorkBench
New Model -> Add diagram -> Design tabels -> Export SQL Script file
Create Database on MAMP
Enter MAMP MySQL in terminal:
$/Applications/MAMP/Library/bin/mysql -uroot -p
password : ‘root’excute .sql file
$source '.sql file directory'
- MySQL Commands
1
2
3
4
5
6show databases;
use 'DB_name';
show tables;
insert into 'table_name' values (v1 for column 1, v2, ...);
// can also insert by phpMyAdmin or MySQLWorkBench
select * from 'table_name';
MySQL column flags meaning
flag | meaning |
---|---|
PK | primary key |
NN | not null |
UQ | unique |
BIN | binary (larger than text) |
UN | unsigned (not negtive) |
ZF | zero fill (fill with 0, e.g int(4) 1 -> 0001) |
AI | auto increment (for id#) |
G | generated column |
\g \G in SELECT statement:
\g -> ; (a statement terminator)
\G -> causes the display to be laid out vertically
php connect to database in MAMP
change MySQL port to 8889
1 | // /lib/db.php |
full example to test if it connected to database
1 | $dbms='mysql'; //database type |