什么是PHP中的C#lock语句?

问题描述:

对于并发和确保数据的完整性,您将如何获得给定对象的互斥锁定?

For concurrency and ensuring the integrity of the data, how would you obtain a mutual-exclusion lock for a given object? Would you need to use locking within the database, or a file, or does PHP support something like this?

PHP不会在数据库或文件中使用锁定, t支持多线程,因此没有对象的锁定机制。如果您要锁定文件,可以使用羊群。没有必要锁定数据库,因为数据库引擎通常可以处理多个连接。

PHP doesn't support multithreading so there's no locking mechanism for objects. If you want to lock a file you could use flock for that. There's no need to lock database as database engines usually can handle multiple connections.