日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

php fetchassoc 跨表,php-mysqli_fetch_assoc-如果同时更改数据会怎样?

發(fā)布時(shí)間:2025/3/21 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php fetchassoc 跨表,php-mysqli_fetch_assoc-如果同时更改数据会怎样? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在PHP中,我在while循環(huán)中使用mysqli_fetch_assoc()來(lái)獲取特定查詢中的所有記錄.

我想知道如果在運(yùn)行循環(huán)時(shí)(通過(guò)另一個(gè)進(jìn)程或服務(wù)器)更改了數(shù)據(jù),從而使記錄不再與查詢匹配,會(huì)發(fā)生什么情況.還會(huì)取嗎?

換句話說(shuō),當(dāng)您執(zhí)行query()時(shí),獲取的記錄數(shù)組是否固定?還是不是?

更新:

我了解這是一項(xiàng)功能,即在更改數(shù)據(jù)時(shí)結(jié)果集不會(huì)更改,但是如果您確實(shí)想這樣做,該怎么辦?在我的循環(huán)中,我對(duì)其他服務(wù)器已更新的記錄不感興趣.我該如何檢查,而不必對(duì)獲取的每個(gè)記錄進(jìn)行新查詢?

更新:

詳細(xì)說(shuō)明:

我正在研究某種搜索引擎抓取工具,用于在數(shù)據(jù)庫(kù)中搜索值.這是由幾個(gè)服務(wù)器同時(shí)完成的.報(bào)廢的物品將不再被搜索.我真的無(wú)法控制哪個(gè)服務(wù)器搜索哪個(gè)項(xiàng)目,我希望可以在獲取記錄集的同時(shí)檢查項(xiàng)目的狀態(tài).由于這是一個(gè)很大的數(shù)據(jù)集,因此我不會(huì)在搜索之前轉(zhuǎn)移整個(gè)結(jié)果集,而是在需要時(shí)提取每條記錄…

解決方法:

介紹

I’m wondering what happens if the data is changed while running the loop (by another process or server), so that the record doesn’t match the query any more. Will it still be fetched?

是.

In other words, is the array of records that are fetched fixed, when you do query()? Or is it not?

是.

如果DBMS容易受到表更新和查詢結(jié)果集迭代之間的競(jìng)爭(zhēng)條件的影響,那將是不值得的.

當(dāng)然,就數(shù)據(jù)庫(kù)本身而言,在更改任何數(shù)據(jù)之前,您的SELECT查詢已經(jīng)完成.結(jié)果集將緩存在數(shù)據(jù)庫(kù)和PHP腳本之間的層中的某個(gè)位置.

深入的

In the context of databases, a single logical operation on the data is called a transaction.

用戶啟動(dòng)的事務(wù)可以包含多個(gè)連續(xù)查詢,但是ISO / IEC 9075-2中的4.33.4和4.33.5描述了如何在每個(gè)查詢級(jí)別隱式進(jìn)行查詢:

The following SQL-statements are transaction-initiating

SQL-statements, i.e., if there is no current SQLtransaction, and an

SQL-statement of this class is executed, then an SQL-transaction is

initiated, usually before execution of that SQL-statement proceeds:

All SQL-schema statements

The following SQL-transaction statements:

.

.

.

.

The following SQL-data statements:

[..]

.

.

.

[..]

[..]

另外,4.35.6:

Effects of SQL-statements in an SQL-transaction

The execution of an SQL-statement within an SQL-transaction has no

effect on SQL-data or schemas [..]. Together with serializable

execution, this implies that all read operations are repeatable

within an SQL-transaction at isolation level SERIALIZABLE, except

for:

1) The effects of changes to SQL-data or schemas and its contents

made explicitly by the SQL-transaction itself.

2) The effects of differences in SQL parameter values supplied to externally-invoked

procedures.

3) The effects of references to time-varying system

variables such as CURRENT_DATE and CURRENT_USER.

您的廣泛要求

I understand that it’s a feature that the resultset is not changed when the data is changed, but what if you actually WANT that? In my loop I’m not interested in records that are already updated by another server. How do I check for that, without doing a new query for each record that I fetch??

你不可以.

盡管可以控制連接器執(zhí)行的緩沖類型(在本例中為MySQLi),但不能覆蓋上述SQL的低級(jí)事實(shí):INSERT或UPDATE或DELETE都不會(huì)影響正在進(jìn)行的SELECT.

SELECT完成后,結(jié)果是獨(dú)立的.您可以控制此獨(dú)立數(shù)據(jù)的傳輸緩沖,但這并不能真正幫助您完成聽(tīng)起來(lái)像您想做的事情.

坦率地說(shuō),這很幸運(yùn),因?yàn)槟胱龅氖虑槁?tīng)起來(lái)很奇怪!

標(biāo)簽:mysqli,php

來(lái)源: https://codeday.me/bug/20191208/2088560.html

總結(jié)

以上是生活随笔為你收集整理的php fetchassoc 跨表,php-mysqli_fetch_assoc-如果同时更改数据会怎样?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。