您的位置:首页 > 编程语言 > PHP开发

强哥PHP学习笔记

2017-06-23 14:41 567 查看


1.php的代码,必须放在.php的文件中,php代码必须写在<?php ?>之间。

2.//单行注释 /* 多行注释 */

3.默认首页index.php index.html index.htm,优先级从左到右。
在Apache的配置文件里设置
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>

4.如果是个纯php页面,那么最后的?>可以不写,也最好别写。

<?php
5.
$name='tudou';
echo '{$name}';

6.变量名区分大小写,函数名不区分大小写

7.变量输出:
echo($name); //输出变量
var_dump($name); //输出数组,并且打印类型和长度,访问同一个元素3次后会停止
print_r($name); //输出数组

8.变量用法:
a.普通变量 $name='aaa';
b.可变变量
$name='aaa';
$$name='bbb';
c.变量引用
$a=10;
$b=&$a; //把$a的内存地址给了$b,那么修改$b的值,$a的肯定也被修改
$b=20;

echo $a;
echo "<br>";
echo $b;
20
20

$a=$b 是把$b的值赋给$a
$a=&$b 是把$b的地址给$a

9.php变量类型:
a.整型 // php中,3/2 = 1.5
b.浮点型
c.字符串
d.布尔型 // 2=="2" 真。等于。不判断类型。 2==="2" 假。全等于。判断类型。
//以上四种类型是标量
e.数组
f.对象 // 对象由两部分组成:特种和功能,在程序中叫属性和方法。
//以上两种是复合类型
g.资源
h.null
//以上两种是特殊类型

php连接符是.不是+
$a='hello';
echo $a.'world';

echo输出布尔值时,true会变成1,false会变成空。所以用var_dump()就可以显示类型了。

数组:
$arr=array('a','b','c');
echo "<pre>";
print_r($arr);
var_dump($arr);
echo "</pre>";
echo $arr[1];
$arr[]='d'; //会自动往后加一个值


面向对象方法:
<?php
header('content-type:text/html;charset=uft-8'); //在这里写header头,设置编码。header头前面不允许有输出。
class per{
function say(){
echo '<h1>我正在说话!</h1>';
}
function eat(){
echo '<h1>我正在吃饭!</h1>';
}
function sleep(){
echo '<h1>我正在睡觉!</h1>';
}
}

$user=new Per();
var_dump($user);
$user->eat();

资源
$conn=mysql_connect('localhost','root','123')
$conn2=mysql_connect('localhost2','root','123')
mysql_select_db('test');
mysql_query('set names utf8');
$sql='select * from user';
$rst=mysql_query($sql);
while ($row=mysql_fetch_assoc($rst)) {
echo '<h1>ID:{$row['id']}</h1>';
echo '<h1>Name:{$row['name']}</h1>';
# code...
}

mysql_query('查看数据库',$conn2);

//$conn和$conn2是连接数据库资源

10.isset和empty两个函数的区别:

isset 变量是否存在
不存在:
a.没有定义
b.null
$name='user1';
var_dump(isset($name));

empty 变量是否为空
为空:
a.0
b.""
c."0"
d.false
e.array()
f.null
g.没有定义

11.类型测试
变量类型测试
a.整型 is_int();
b.浮点型 is_float();
c.字符串 is_string();
d.布尔型 is_bool();
e.数组 is_array();
f.对象 is_object();
g.资源 is_resource();
h.null is_null();
is_scalar(); //测试是否是标量(整型、浮点型、字符串、布尔型)
is_numeric(); //测试是否是数字(整型、浮点型)
is_callable(); //测试是否是函数,而不是语言结构
常用的语言结构:
a.echo();
b.print();
c.array();
d.list();
……

12.类型自动转换-标量
a.整型 --> 字符串
$num = 123;
echo $num.'abc';

b.字符串 --> 整型
$str='123';
echo $str+1;

c.其他类型 --> 布尔型
a.0
b.""
c."0"
d.false
e.array()
f.null
g.没有定义
//以上都为false,其余为真

$num=0;
if($num){

}
var_dump($num);


13.类型强制转换-标量
(int)$num
(float)$num
(string)$num
……

14.字符串的单双引号
$str1='hello';
$str2='world';
echo $str.' '.$str2;
echo '我是{$str1},我想……';
//单引号比双引号的执行速度要快得多,但是,在单引号中,变量无法被解析。这也是单引号比双引号快的原因。
//字符串中没有变量需要解析就用单引号,否则就用双引号或者单引号(用.连接)

15.删除变量
$name="user1";
unset($name)
var_dump(isset($name));

16.常量的定义:
//跟变量一样,但是一旦被定义就不能被修改
define('HOST', 'localhost'); //前面是名字,后面是值
define('USER', 'root');//

//比如数据库连接的配置文件,这个时候就要用常量,而且后面不能被修改。

<?php
include('config.inc.php');//加载同目录下的配置文件。

echo 'my host is '.HOST;//常量不能放到双引号里面去
$conn=mysql_connect(HOST,USER,PASS);
$conn2=mysql_connect('localhost2','root','123');
mysql_select_db('test');
mysql_query('set names utf8');
$sql='select * from user';
$rst=mysql_query($sql);
while ($row=mysql_fetch_assoc($rst)) {
echo '<h1>ID:{$row['id']}</h1>';
echo '<h1>Name:{$row['name']}</h1>';
# code...
}

注:mysql中的test数据库,用root登陆,密码即使不正确,也可以匿名登录!!

17.预定义常量:
PHP_OS //系统平台
PHP_VERSION //php版本
__LINE__ //常量所在行数
__FILE__ //文件绝对路径
__FUNCTION__ //显示函数名
M_PI //圆周率

18.运算符:
a.一元
$num++
$num--
//先赋值后运算
++$num
--$num
//先运算,后赋值

$a=2;
$b=$a++; //先赋值,后运算
$b=++$a;//选运算,后赋值
echo $a;
echo '<br>';
echo $b;


b.二元
+ - * / %
//数学运算符
+= -= *= /= %= //和Python里的一样
//赋值运算符
> < >= <= == != === !==
//比较运算符
&& //有开关功能,前面为真才执行后面
|| //有开关功能,前面为假才执行后面
!
//逻辑运算符
$a=0;
$b=4;
if($c=($a&&$b=6)){ //$a已经是假,所以$b=6不会执行,这就是所谓的开关,走到这里开关已经关上了。
echo '1';
}else{
echo'2';
}
var_dump($a);
var_dump($b);
var_dump($c);
//输出值。0,4,false
//

c.三元
?:
$a=3;
if ($a<3) {
$num=3;
# code...
}else{
$num=$a;

}
//以上if语句可简化如下
$num=$a<3?3:$a;


运算符优先级

@运算符://屏蔽函数报错
$conn=@mysql_connect('localhost','root','123');


数组运算符:
=>//给数组加字母下标,自定义下标
$arr=array('user1','user2','user3'); //索引数组
$arr=array('name'=>'user1','age'=>'30');//关联数组(我觉得像字典)


对象运算符:
->
$user->say();

19.流程控制:
分支结构
if ...elseif...else
switch...case

循环控制
for
while

终止循环
break
continue

剩余部分
a.do...while
d.99乘法表

终止脚本:
b.exit();
c.die();

20.函数
语言结构
自定义函数
变量作用域
静态函数
函数返回值
参数
默认参数
引用参数
可变个数参数
回调函数
变量函数
递归函数
文件包含


函数分类
1.自定义函数
2.回调函数
3.变量函数
4.递归函数

语言结构
if();
for();
while();
switch();

echo();
print();

array();
list();
foreach();

isset();
unset();
empty();

exit();
die();

include();
require();

自定义函数:
function fun(){}
调用函数:
fun();

function sum($a,$b){
echo $a+$b;
}
echo "1+2=".sum(1,2);

输出结果:31+2= //经测试,Python计算方式也是如此,不过会多一个None


函数的结果:
1.输出结果
2.返回结果

func_num_args();//返回传入参数的个数
func_get_args();//返回传入参数的值
array_sum();//计算数列的和


变量函数
function sum($i,$j){
return $i+$j;
}
$a="sum";//变量函数
echo $a(1,2);


$num=10;
function fun(&$i){
$i++;
}
fun($num);//直接在内存地址中计算,所以输出11
echo $num;

引用参数:
函数内部和函数外部指向同一个变量的地址,改变函数内部的变量值,函数外面也会发生变化

回调函数:
一个函数的参数是另一个函数的名字,那么这个参数就叫回调函数

静态变量:
多次跟踪同一个函数,静态变量可以一直跟踪下去

包含文件:
include();//报错后代码继续执行
require();//报错后终止

递归函数:
函数里面调用本函数

php的执行过程:
1.加载页面
2.语法检测(1.语法检测 2.加载函数)
3.执行脚本


数组:
1.数组定义和遍历
2.数组函数

数组定义:
$arr=array(1,2,3);//索引数组
$arr=array("name"=>"user1","age"=>30);//关联数组

数组下标:
$arr=array("name"=>1,2,"age"=>3,4,100=>5,6,5=>7,8);
[name] => 1
[0] => 2
[age] => 3
[1] => 4
[100] => 5
[101] => 6
[5] => 7
[102] => 8
//如果不是自定义下标,下标永远是上一个数字下标加1.

数组取值:
1.输出整个数组:
print_r();
2.取某一个值:
echo $arr['arr'];
echo $arr[100];

数组赋值:
$arr['age']=30;//和Python一样

数组赋值定义数组:
$arr[]=1;
$arr[]=2;

数组遍历:
1.for循环
2.foreach循环
3.while...list...ecah循环
//推荐使用foreach

for(){

}
//

foreach ($arr as $key=>$val){
echo "<h1>{$key}:{$val}</h1>";
}
//Python里的遍历字典

while (list($key,$val)=each($arr)){
echo $key.$val;
//print_r($row);
}

多维数组:
1.一维数组$arr=array(1,2,3);
$arr[0];
2.二维数组$arr=array(1,2,arr(4,5));
$arr[2][0];
3.三维数组$arr=arrar(1,2,array(3,array(4,5)));
$arr[2][1][0];

超全局数组:
$_SERVER
$_GET
$_POST
$_REQUEST
$_FILES
$_COOKIES
$_SESSION
$GLOBALS

$_SERVER 查看服务器信息:
print_r($_SERVER);

$_GET 获取get提交过来的数据

两个页面之间通讯
1.表单(get方式 post方式)
2.a标签传值(get方式)

a标签推荐使用get方式提交数据
表单推荐使用post方式提交数据

$_POST
获取表单post过来的数据

$_REQUEST
获取a或表单get或post过来的数据 //不建议使用,处理速度慢

$_COOKIE
同一个变量在多个页面获取到

$_SESSION
同一个变量在多个页面获取到

$_FILES
获取表单中的文件,并生成一个数组

$GLOBALS
$GLOBALS[SCRIPT_FILENAME]
$GLOBALS[username] //里面包含页面内的全局变量,并且通过$GLOBALS[username]="user2"改变$username的值

数组处理函数
1.array_keys();
2.array_values();
3.in_array();
4.array_key_exists();
5.array_flip();
6.array_reverse();

统计数组的元素和唯一性:
1.count
2.array_count_values();
3.array_unique();

使用回调函数处理数组的函数:
1.array_filter();
2.array_map();

引用参数:
需求:数组值自加1
function add($$arr){
foreach ($arr as $key => $value) {
$arr[$key]=$val+1;
}
}

数组的排序函数:
1.sort(); 升序,不保留key
2.rsort(); 降序,不保留key
3.asort(); 升序,保留key
4.arsort(); 降序,保留key
5.ksort(); key排序
6.krsort(); key排序
7.natsort(); 自然排序
8.natcasesort(); 自然排序不区分大小写
9.array_multisort(); 多数组排序

字符串知识点:
1.字符串的处理介绍
2.常用的字符串输出函数
3.常用的字符串格式化函数
4.字符串比较函数
5.正则表达式在字符串中的应用
6.与Perl兼容的正则表达式函数

字符串输出:
1.echo
2.print
3.printf()
4.sprintf()

字符串连接符:
.用点连接
去除空格和字符串填补函数:
1.ltrim() //去除左空格
2.rtrim() //去除右空格
3.trim() //去除左右空格
4.str_pad() //返回填充后的字符串
5.str_repeat() //重复一个字符串
6.strlen() //获取字符串长度

字符串大小写转换:
1.strtoupper() //转大写
2.strtolower() //转小写
3.ucfirst() //行首字母大写
4.ucwords() //词首字母大写

其他字符串格式化函数:
1.strlen()
2.strrev() //翻转字符串
3.number_format() //类似货币的格式化123,456,789
4.md5() //md5加密
5.str_shuffle() //随机打乱字符串顺序(验证码)

与html标签相关联的字符串函数
1.nl2br()把\n转成<br>标签
2.htmlspecialchars() 转实体
3.strip_tags() 去掉html标签,也可以保留一部分
4.addslashes() 转义' " \,在他们前面加\,默认php开启 '
5.stripcslashes() 去掉addslashes前面加的反斜线\

建议在数据库插入之前进行三道把控
1.标签过滤
ssssss
2.addcslashes()
// ' " 前加\防止对数据库造成破坏
3.htmlspecialchars()
把<>''""转成实体,防止对数据库造成破坏

字符串比较函数
1.strcmp(str1, str2) //
2.strcasecmp(str1, str2)

按自然排序法时字符串的比较
1.strnatcmp(str1, str2)
2.strnatcasecmp(str1, str2)

字符串截取
1.substr(string, start)
2.mb_substr(str, start)

查询字符串位置
1.strstr(haystack, needle)
2.strrchr(haystack, needle)
3.str_replace(search, replace, subject) //替换字符串

字符串拆分常用函数:
1.pathinfo(path);
2.parse_url(url);
3.parse_str(str);

正则表达式:
1.原子
2.元字符
3.模式修正符

正则表达式函数
1.preg_match(pattern, subject)
2.preg_match_all(pattern, subject, matches)
3.preg_grep(pattern, input)
4.preg_replace(pattern, replacement, subject)
5.preg_split(pattern, subject)

原子
. 任意一个字符
\w 字母、数字、下划线
[] 里面任意一个字符
[^abc] 它里面除了abc的任意字符
() 一个单元
\d 任意一个数字
\D 任意一个非数字
\w 任意一个字母、数字、下划线
\W 除了空白字符、数字、下划线以外任意一个字符
\s 空白字符
\S 除空白字符外的任意字符
有特殊含义的加\

模式修正符
i,m,s,U,e
i 忽略大小写
m 视为多行
s 视为单行
U 贪婪模式,最大化匹配
e 如果设定了此修正符,preg_replace() 在替换字符串中对逆向引用作正常的替换,将其作为 PHP 代码求值,并用其结果来替换所搜索的字符串。

 

 



元字符
* 0个、1个、多个
+ 1个、多个
? 0个、1个
| 或
^ 开头
$ 结尾
\b 词边缘
\B 非词边缘
{m} m个
{n,m} n到m个
{n,} n个前面原子

数学函数
日期函数
错误处理
字符串分割
preg_split(pattern, subject)

数学函数

1.max(values)
2.min(values)
3.mt_rand() 随机数
4.ceil()
5.floor() 地板除
6.pi()
7.rand() 四舍五入

日期函数
1.time(oid)
2.date(format)
3.strtotime(time)
4.microtime() //微秒
microtime(1) 方便参与数学运算

date参数
Y 2013
y 13
m 03
n 3
d 05 号
j 5 号
H 24小时制
h 12小时制
i 05 分钟
s 05 秒
w 0-6 周日到周六
t 31 一个月天数
L 是否为闰年

实例:万年历
1.几年几月几日
2.周日到周六
3.一号是星期几
4.这个月有多少天
5.下一年和上一年
6.上一月和下一月

php错误处理:
1.关闭和开启报错
2.报错级别
3.报错地方

关闭和开启报错:
display_errors = On

E_ALL //所有错误
E_ERROR //严重错误
E_WARNING //警告错误
E_PARSE //语法错误
E_NOTICE //提示错误

报什么级别的错:
error_reporting = E_ALL

E_ALL & ~E_NOTICE 所有,除了notice

display_errors = On //是否从浏览器输出错误

log_errors = off //是否把错误日志写入错误日志
error_log = d:\php.log

 

gd库画图
1.准备画布
imagecreatetruecolor(width, height);
2.准备涂料
3.画画
4.输出图
5.保存图
6.关闭画布

图片处理函数实用场景
1.验证码
2.缩放
3.裁剪
4.水印

绘制图像
imagefill(image, x, y, color) 填充
imageellipse(image, cx, cy, width, height, color) 椭圆
imagesetpixel(image, x, y, color) 点
imageline(image, x1, y1, x2, y2, color) 线
imagerectangle(image, x1, y1, x2, y2, color) 矩形
imagepolygon(image, points, num_points, color) 多边形
imagearc(image, cx, cy, width, height, start, end, color) 圆弧
imagestring(image, font, x, y, string, color) 字符串
imagechar(image, font, x, y, c, color) 单个字符
imagettftext(image, size, angle, x, y, color, fontfile, text)

php验证码设计:

页面跳转
1.header('location:index.php');
2.js跳转
echo "<script>loaction='index.php'</script>";

获取图片的宽度
1.getimagesize(filename)
2.imagesx(image)
3.imagesy(image)
已经存在的图片形成画布资源
1.imagecreatefromjpeg(filename)
图片缩放函数
imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)

图片等比例缩放

图片裁剪函数
imagecopyresampled();
图片水印函数
imagecopy(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h)

文件操作
filetype(filename)
is_dir(filename)
is_file(filename)
file_exists(filename) //文件和目录是否存在
filesize(filename)
unlink(filename) //文件删除
新建文件 fopen(filename, mode)
删除文件 unlink(filename)
文件重命名 rename(oldname, newname)
文件复制 copy(source, dest)
文件移动

打开文件 fopen(filename, mode)
读取文件
写入文件 fwrite(handle, string)
r+ 擦除写
w+ 清空写

关闭文件 fclose(handle)

file(); //把文件以数组返回
readfile(); //抛出文件内容,包括图片
file_get_contents(); //获取文件内容
file_put_contents($filename,$str,FILE_APPEND); //写入文件内容
rewind(handle) //将指针返回文件开头
feof(); //判断指针是否到了文件结尾

mkdir(); //创建目录
rmdir(); //删除目录
与路径有关的函数
basename();
dirname();
pathinfo();
__FILE__; //输出绝对路径
realpath(); //当前目录或者上级目录的绝对地址
DIRECTORY_SEPARATOR;
PATH_SEPARATOR;
parse_url();
parse_str();

遍历目录:
opendir();


文件上传
1.表单
<from action="upload.php" method='post' ecctype="multipart/form-data">
<input type="file" name="file">
</from>
2.上传php页面
move_uploaded_file(filename, destination)

$_FILES['myfile']['error']
0 无错误
1 上传文件大小超过约定值
2 上传文件大小超过表单限制
3 文件只被部分上传
4 没有上传任何文件

文件下载
header("content-type:application/octet-streame");
header("content-disposition:attachment;filename={$imgfile}");
header("content-lenth:{$imagesize}");
readfile('a.txt');

move_uploaded_file(filename, destination)

php.ini
upload_max_filesize = 200M
post_max_size = 80M


php操作mysql数据库

1.通过php连接mysql
2.选择数据库
3.insert
4.delete
5.update
6.select

通过php连接mysql
mysql_connect('localhost','root','123');

选择数据库
mysql_select_db('test');

设置客户端和连接字符集
mysql_query('set names utf8');

通过php进行insert操作

释放连接资源
mysql_close($conn);

从结果集中取数据:
mysql_fetch_assoc 关联数组
mysql_fetch_row 索引数组
mysql_fetch_array 混合数组
mysql_fetch_object 对象

从结果中取全部数据:
while($row = mysql_fetch_assoc($result)){
echo "<pre>";
print_r($row);
echo "</pre>";
}

mysql_error(); //mysql错误信息
mysql_errno(); //mysql错误编码

mysql_insert_id(); //取得上一步insert插入的ID
mysql_affected_rows(); //取得最近一次INSERT,UPDATE 或 DELETE 查询所影响的记录行数
mysql_num_rows(); //得到select操作影响的行数

网站系统
1.目录结构
前台 home
后台 admin
前台入口文件 index.php

2.需求分析
后台:
用户管理
分类管理
品牌管理
商品管理

订单状态管理
订单管理

前台:
首页
品牌页面
商品详情
商品评论管理
购物车管理
结算页面
用户登录和退出
个人中心管理
订单提交页面

3.目录结构细化
myshop
------------
|--index.php 网站首页(跳转到home/index.php前台首页)
|
|--public/ 公共资源目录(前后台共用的数据库连接文件和函数库)
| |--common/ 函数库
| | |--config.inc.php 公共配置文件
| | |--functions.php 函数库文件
| |--images/ 公共图片
| |--css/ 公共css
| |--upload/ 公共图片上传
| | |--admin/ 后台图片上传
| | |--home/ 前台图片上传
|
|--admin/ 后台管理目录
| |--index.php 后台网站首页
| |--login/
| | |--login.php 后台登陆页
| | |--check.php 登陆验证页
| | |--logout.php 后台退出页
| |
| |--public/ 公共资源目录
| | |--css/ 存放后台css文件目录
| | |--js/ 存放后台js文件目录
| | |--imgs/ 存放后台图片目录
| | |--header.php 页头
| | |--menu.php 导航栏页面
| | |--main.php 后台首页
| | |--acl.php 网站后台权限文件
| |
| |--user/ 用户管理目录(普通用户和管理员共用表)
| | |--index.php 浏览信息
| | |--add.php 添加信息
| | |--insert.php 插入信息
| | |--edit.php 编辑信息
| | |--update.php 更改信息
| | |--del.php 删除信息
| |
| |--shopclass/ 商品分类管理
| | |--index.php 浏览信息
| | |--add.php 添加信息
| | |--insert.php 插入信息
| | |--edit.php 编辑信息
| | |--update.php 更改信息
| | |--del.php 删除信息
| |
| |--brand/ 品牌管理
| | |--index.php 浏览信息
| | |--add.php 添加信息
| | |--insert.php 插入信息
| | |--edit.php 编辑信息
| | |--update.php 更改信息
| | |--del.php 删除信息
| |
| |--shop/ 商品信息管理
| | |--index.php 浏览信息
| | |--add.php 添加信息
| | |--insert.php 插入信息
| | |--edit.php 编辑信息
| | |--update.php 更改信息
| | |--del.php 删除信息
| | |--updown.php 商品上下架页面
| |
| |--order/ 订单信息管理
| | |--index.php 浏览信息
| | |--status.php 编辑订单状态
| | |--update.php 更改订单状态
|
|
|--home/ 网站前台目录
| |--public/ 公共资源目录
| | |--css/ 存放前台css文件目录
| | |--images/ 存放前台图片文件目录
| | |--header.php 前台导航页面
| | |--footer.php 前台底部页面
| | |--acl.php 网站前台权限文件
| |
| |--index.php 前台首页
| |
| |--brandlist.php 品牌列表页(分页实现,显示单个品牌下的)
| |
| |--shopinfo.php 商品详情页(单个商品的放入购物车页面,下面有商品评论)
| |
| |--cart/ 购物车管理
| | |--addcart.php 加入购物车
| | |--clearcart.php 清空购物车
| | |--opcart.php 操作购物车(add,rem,del操作)
| |
| |--account.php 结算页面
| |
| |--ordercommit.php 提交订单(把购物清单插入到订单表,让后台使用)
| |
| |--center.php 个人中心(用户信息[密码,地址,电话,邮箱],查看我的订单)
| |
| |--user/
| | |--register.php 注册
| | |--login.php 登陆
| | |--check.php 验证
| | |--logout.php 退出
| |


4.数据库设计
-- user表
-- 用户表
create table if not exists user(
id int unsigned not null auto_increment,
username varchar(50) not null,
password varchar(50) not null,
regtime int not null,
admin tinyint not null,
primary key(id)
);

 

-- shopclass表
-- 商品分类
create table if not exists shopclass(
id int unsigned not null auto_increment,
name varchar(50) not null,
primary key(id)
);

 

-- brand表
-- 品牌
create table if not exists brand(
id int unsigned not null auto_increment,
name varchar(50) not null,
shopclass_id int not null,
primary key(id)
);

 


-- shop表
-- 商品表
create table if not exists shop(
id int unsigned not null auto_increment,
name varchar(50) not null,
price float not null,
stock int not null,
upshelf tinyint not null,
image varchar(100) not null,
brand_id int not null,
primary key(id)
);


-- orderstat表
-- 订单状态
create table if not exists orderstat(
id int unsigned not null auto_increment,
name varchar(50) not null,
primary key(id)
);

 

-- relation表
-- 联系方式
create table if not exists relation(
id int unsigned not null auto_increment,
realname varchar(50) not null,
address varchar(200) not null,
telephone varchar(20) not null,
email varchar(50) not null,
user_id int not null,
primary key(id)
);

 

-- orders表
-- 订单表
create table if not exists orders(
id int unsigned not null auto_increment,
code varchar(50) not null,
user_id int not null,
shop_id int not null,
num int not null,
price float not null,
time int not null,
orderstat_id int not null,
relation_id int not null,
primary key(id)
);

 

-- commit表
-- 评论
create table if not exists commit(
id int unsigned not null auto_increment,
content text,
user_id int not null,
shop_id int not null,
primary key(id)
);


5.组合sql语句

6.导入数据库

7.php程序编写

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: