Pre*_*bia 0 php mysql database
我想用php和mysql创建一个应用程序.
假设我正在进行api调用并获取网址列表.我想存储这些网址,每个网址应该有一个uniqe id(即数字),以便我可以将该ID传递给某个页面,我可以从我的数据库中获取网址.
假设我做了一个api调用得到五个关键字"xyz"的网址,我得到了以下网址和各自的标题
google.com/abc1.html title1
google.com/abc2.html title2
google.com/abc3.html title3
google.com/abc4.html title4
Run Code Online (Sandbox Code Playgroud)
所以我想生成每个网址的唯一ID
id1 google.com/abc1.html title1
id2 google.com/abc2.html title2
id3 google.com/abc3.html title3
id4 google.com/abc4.html title4
Run Code Online (Sandbox Code Playgroud)
约束是url应该是唯一的
数据库可以容纳12个左右的URL.
你能指导我如何实现吗?还给出了一些优化指南
谢谢
对id使用auto_increment列,在url列上使用唯一约束.
create table urls (
id bigint not null auto_increment
, url varchar(250) unique
, title varchar(250)
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2165 次 |
| 最近记录: |