In the last content, we realized the format of emptying the shopping cart and the amount. The module that implements the order this time.
1. First, we create the order table in the database, and create the SQL of the table as follows:
CREATE TABLE orders (
ID int not NULL auto_increment,
name varchar (MB) NOT NULL,
email varchar (255) NOT NULL, Address
text is not NULL,
Pay_type char (a) not NULL,
primary key (ID)
);
We'll also re-create the Line_item table, and here's the SQL:
CREATE TABLE Line_items (
ID int not NULL auto_increment,
product_id int not NULL,
order_id Int. not NULL,
quantity int NOT NULL default 0,
unit_price decimal (10,2) NOT NULL,
constraint fk_items_product foreign key ( PRODUCT_ID) references products (ID),
constraint Fk_items_order foreign key (order_id) references orders (ID),
primary KEY (ID)
);
In Instantrail, you can use phpMyAdmin to execute SQL.
Run the command line, generate the order model, as shown in figure: