Friday, December 12, 2014

MySQL in PHP

Mysql Port
mysql_default_port -> 3306

There are two types of database
1. relational database (Normalization)
2. NoSQL(MangoDB) -> Here is query 100 times fast

Naming Conventions
1. Always use plural in table name
e.g. table name should be users not user
2. Always write command in uppercase
e.g. SELECT * FROM `users`
3. always have table name in lowercase
e.g. users
4. Use _ in b/w two words of table name
e.g. users_data

Type
DDL -> CREATE, DROP, ALTER, RENAME, TRUNCATE
DML -> INSERT, UPDATE, DELETE, SELECT
DCL -> REVOKE, GRANT
TCL -> BEGIN, SAVEPOINT, COMMIT, ROLLBACK

TRUNCATE -> Delete Complete Data from the table except the structure
CREATE -> To Create Table or Database
INSERT -> To Insert data in table
DROP -> To Drop particular Table or Database
UPDATE -> To Update data in table
DELETE -> To Delete Data from the table
ALTER -> To Change the structure of table
COMMIT ->
SELECT -> To Select the data from the Table
RENAME ->
ROLLBACK ->
REVOKE ->
BEGIN ->
SAVEPONIT ->

Useful Functions
mysql_connect
mysql_select_db
mysql_query
mysql_fetch_array
mysql_fetch_assoc
mysql_fetch_object
mysql_fetch_row

Note:-
In Mysqli we can connect with multiple database at the 

No comments:

Post a Comment