(沒有版本資訊,可能只在 Git 中)
RowResult::fetchAll — 從結果集中取得所有列
此函式沒有參數。
一個包含查詢所有結果的數值索引陣列;每個結果都是一個關聯式陣列。如果沒有任何列,則會傳回一個空陣列。
範例 #1 mysql_xdevapi\RowResult::fetchAll() 範例
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();
$session->sql("CREATE TABLE addressbook.names(name text, age int)")->execute();
$session->sql("INSERT INTO addressbook.names values ('John', 42), ('Sam', 33)")->execute();
$schema = $session->getSchema("addressbook");
$table = $schema->getTable("names");
$row = $table->select('name', 'age')->execute()->fetchAll();
print_r($row);
以上範例將輸出類似以下的內容:
Array ( [0] => Array ( [name] => John [age] => 42 ) [1] => Array ( [name] => Sam [age] => 33 ) )