|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
把例子全部敲进去试验,完成一遍以后就会有心得了,因为你会发现为啥我的程序和书上的一模一样就是结果不正确。新手学习的时候必须承认,不容易,因为我也是过来人,你会发现原来有那么多常用的语句,函数都要记。 本级法式所用的数据表布局:
# --------------------------------------------------------
#
# 数据表的布局 'author'
#
CREATE TABLE author (
author_id int(6) DEFAULT '0' NOT NULL auto_increment,
first_name varchar(20) binary NOT NULL,
last_name varchar(20) NOT NULL,
address varchar(100) binary NOT NULL,
zipcode varchar(10) NOT NULL,
telephone varchar(10) NOT NULL,
email varchar(50) NOT NULL,
comment varchar(255) NOT NULL,
PRIMARY KEY (author_id),
KEY first_name (first_name),
KEY last_name (last_name),
KEY address (address),
KEY zipcode (zipcode),
KEY email (email)
);
# --------------------------------------------------------
#
# 数据表的布局 'books'
#
CREATE TABLE books (
books_id int(6) DEFAULT '0' NOT NULL auto_increment,
books_name varchar(100) binary NOT NULL,
publisher_id varchar(6) NOT NULL,
date_pub datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
type varchar(6) NOT NULL,
pages varchar(4) NOT NULL,
price float(6,2) DEFAULT '0.00' NOT NULL,
comment varchar(255) binary NOT NULL,
ISBN varchar(25) NOT NULL,
PRIMARY KEY (books_id),
KEY name (books_name),
KEY publisher (publisher_id),
KEY date_pub (date_pub),
KEY price (price),
KEY pages (pages),
KEY type (type),
KEY ISBN (ISBN)
);
# --------------------------------------------------------
#
# 数据表的布局 'books_author'
#
CREATE TABLE books_author (
id int(6) DEFAULT '0' NOT NULL auto_increment,
books_id varchar(6) NOT NULL,
author_id varchar(6) NOT NULL,
author_type varchar(6) NOT NULL,
PRIMARY KEY (id)
);
# --------------------------------------------------------
#
# 数据表的布局 'publisher'
#
CREATE TABLE publisher (
publisher_id int(6) DEFAULT '0' NOT NULL auto_increment,
publisher_name varchar(100) binary NOT NULL,
address varchar(100) NOT NULL,
zipcode varchar(10) NOT NULL,
telephone varchar(10) NOT NULL,
telefax varchar(10) NOT NULL,
email varchar(50) NOT NULL,
PRIMARY KEY (publisher_id),
KEY name (publisher_name),
KEY address (address),
KEY email (email)
);
exit来实现结束后面的PHP语句的执行,缩小调试范围,特别是数据库交互的程序,先输出个SQL语句看看,对了,再分析怎么会插入/删除不成功呢?这样对查错很有帮助。 |
|