一、类型:
用户名用:
CHAR:限定字符长度,运算速度快
VARCHAR:可变字符长度,其次
TEXT:文本随便输入,慢
密码:CHAR 18长
name设置:VARCHAR
年龄:int
sex:char
tel电话:CHAR
默认:不给当前属性值时,默认放什么
整理:ascli_bin字符
utf8_bin 数字
A_I:自动累加
二、增删改查操作
INSERT INTO:插入一行
INSERT INTO user
(user
, paaaword
, name
, ago
, sex
, tel
, email
) VALUES (‘zang’,‘zjh123’,‘臧金辉’,‘25’,‘男’,‘15875445366’,‘1396543.@qq.com’)
SELECT *:查找所有内容字段
SELECT * FROM user
WHERE email
LIKE ‘%qq.com’
查找字符里包含qq.com的
AND 同时满足两边条件
删除
DELETE FROM user
WHERE user
=‘za’
UPDATE:修改user='za'的密码为zzzzz UPDATE
userSET
paaaword='zzzzz' WHERE
user`=‘za’
字符单引号‘’
三、php连接数据库
function link_sql(){
s
q
l
=
m
y
s
q
l
i
c
o
n
n
e
c
t
(
"
l
o
c
a
l
h
o
s
t
"
,
"
r
o
o
t
"
,
"
r
o
o
t
"
,
"
g
a
m
e
"
,
"
3306
"
)
;
i
f
(
m
y
s
q
l
i
c
o
n
n
e
c
t
e
r
r
n
o
(
)
)
/
/
如
果
连
接
错
误
e
c
h
o
"
数
据
库
异
常
"
;
r
e
t
u
r
n
;
i
n
s
e
r
D
a
t
a
(
sql=mysqli_connect("localhost","root","root","game","3306"); if(mysqli_connect_errno()){ //如果连接错误 echo "数据库异常"; return; } inserData(
sql=mysqliconnect("localhost","root","root","game","3306");if(mysqliconnecterrno())//如果连接错误echo"数据库异常";return;inserData(sql)
}
//插入固定数据
function inserData($sql){
r
e
s
=
m
y
s
q
l
i
q
u
e
r
y
(
res=mysqli_query(
res=mysqliquery(sql,“insert into user
(user
, paaaword
, name
, ago
, sex
, tel
, email
) VALUES (‘zang’,‘zjh123’,‘臧金辉’,‘25’,‘男’,‘15875445366’,‘1396543.@qq.com’)”);
var_bump($res);//成功就输出
}
link_sql();