日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/3/21 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php fetchassoc 跨表,php-mysqli_fetch_assoc-如果同时更改数据会怎样? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

我想知道如果在運行循環時(通過另一個進程或服務器)更改了數據,從而使記錄不再與查詢匹配,會發生什么情況.還會取嗎?

換句話說,當您執行query()時,獲取的記錄數組是否固定?還是不是?

更新:

我了解這是一項功能,即在更改數據時結果集不會更改,但是如果您確實想這樣做,該怎么辦?在我的循環中,我對其他服務器已更新的記錄不感興趣.我該如何檢查,而不必對獲取的每個記錄進行新查詢?

更新:

詳細說明:

我正在研究某種搜索引擎抓取工具,用于在數據庫中搜索值.這是由幾個服務器同時完成的.報廢的物品將不再被搜索.我真的無法控制哪個服務器搜索哪個項目,我希望可以在獲取記錄集的同時檢查項目的狀態.由于這是一個很大的數據集,因此我不會在搜索之前轉移整個結果集,而是在需要時提取每條記錄…

解決方法:

介紹

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容易受到表更新和查詢結果集迭代之間的競爭條件的影響,那將是不值得的.

當然,就數據庫本身而言,在更改任何數據之前,您的SELECT查詢已經完成.結果集將緩存在數據庫和PHP腳本之間的層中的某個位置.

深入的

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

用戶啟動的事務可以包含多個連續查詢,但是ISO / IEC 9075-2中的4.33.4和4.33.5描述了如何在每個查詢級別隱式進行查詢:

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??

你不可以.

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

SELECT完成后,結果是獨立的.您可以控制此獨立數據的傳輸緩沖,但這并不能真正幫助您完成聽起來像您想做的事情.

坦率地說,這很幸運,因為您想做的事情聽起來很奇怪!

標簽:mysqli,php

來源: https://codeday.me/bug/20191208/2088560.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。