mysql - 求一段php逻辑代码
阿神
阿神 2017-04-10 16:58:08
0
2
699

类似评论的功能
表table1内有字段floor,time,text
如何实现floor自增,同时插入时加锁(防止高并发同floor),最好能有php代码

阿神
阿神

闭关修行中......

Antworte allen(2)
大家讲道理

建表的时候说明floor是自增的就行了,比如
create table table 1 (
floor int not null auto_increment primary,
time...
)....
如果表已经建好了用alter修改一下就行了。
这样死活都重复不了的,和高并发无关。

洪涛

创建数据库的时候不仅仅要把floor设为auto_increment,还必须把存储引擎设了innodb,innodb是行锁,并且写数据是分页的,myisam是表锁,是安partition写的。

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!