PHP8 cubrid_fetch_assoc

2024-03-29 09:17 更新

(PECL CUBRID >= 8.3.0)

cubrid_fetch_assoc — 返回與提取的行相對應的關聯(lián)數(shù)組

說明

cubrid_fetch_assoc(resource $result, int $type = ?): array

此函數(shù)返回關聯(lián)數(shù)組,該數(shù)組對應于 fetched 行,然后將內部數(shù)據(jù)指針向前移動,或返回 當?shù)竭_終點時為 FALSE。

參數(shù) ?

result

result來自對 cubrid_execute() 的調用

type

Type 只能CUBRID_LOB,將使用此參數(shù) 僅當您需要操作 LOB 對象時。

返回值 ?

關聯(lián)數(shù)組,當進程成功時。

false,當沒有更多行時;NULL,當進程不成功時。

示例 ?

示例 #1 cubrid_fetch_assoc() example

<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000");

printf("%-40s %-10s %-6s %-20s\n", "name", "area", "seats", "address");
while ($row = cubrid_fetch_assoc($req)) {
    printf("%-40s %-10s %-6s %-20s\n", 
        $row["name"], $row["area"], $row["seats"], $row["address"]);
}

// if you want to operate LOB object, you can use cubrid_fetch_assoc($req, CUBRID_LOB)

cubrid_close_request($req);

cubrid_disconnect($conn);
?>

以上示例會輸出:

name                                     area       seats  address             
Panathinaiko Stadium                     86300.00   50000  Athens, Greece      
Olympic Stadium                          54700.00   13000  Athens, Greece      
Olympic Indoor Hall                      34100.00   18800  Athens, Greece      
Olympic Hall                             52400.00   21000  Athens, Greece      
Olympic Aquatic Centre                   42500.00   11500  Athens, Greece      
Markopoulo Olympic Equestrian Centre     64000.00   15000  Markopoulo, Athens, Greece
Faliro Coastal Zone Olympic Complex      34650.00   12171  Faliro, Athens, Greece
Athens Olympic Stadium                   120400.00  71030  Maroussi, Athens, Greece 
Ano Liossia                              34000.00   12000  Ano Liosia, Athens, Greece

參見 ?

  • cubrid_execute() - 執(zhí)行準備好的 SQL 語句
  • cubrid_fetch() - 從結果集中提取下一行
  • cubrid_fetch_row() - 返回包含當前行值的數(shù)字數(shù)組
  • cubrid_fetch_array() - 將結果行提取為關聯(lián)數(shù)組和/或數(shù)值數(shù)組
  • cubrid_fetch_object() - 獲取下一行并將其作為對象返回


以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號