mysqli_result::fetch_all

mysqli_fetch_all

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

mysqli_result::fetch_all -- mysqli_fetch_allFetch all result rows as an associative array, a numeric array, or both

Beschreibung

Objektorientierter Stil

public mysqli_result::fetch_all(int $mode = MYSQLI_NUM): array

Prozeduraler Stil

mysqli_fetch_all(mysqli_result $result, int $mode = MYSQLI_NUM): array

Returns a two-dimensional array of all result rows as an associative array, a numeric array, or both.

Hinweis:

Prior to PHP 8.1.0, available only with mysqlnd.

Parameter-Liste

result

Nur bei prozeduralem Aufruf: Ein von mysqli_query(), mysqli_store_result(), mysqli_use_result() oder mysqli_stmt_get_result() zurückgegebenes mysqli_result-Objekt.

mode

This optional parameter is a constant indicating what type of array should be produced from the current row data. The possible values for this parameter are the constants MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH.

Rückgabewerte

Returns an array of associative or numeric arrays holding result rows.

Changelog

Version Beschreibung
8.1.0 Now also available when linking against libmysqlclient.

Beispiele

Beispiel #1 mysqli_result::fetch_all() example

Objektorientierter Stil

<?php

mysqli_report
(MYSQLI_REPORT_ERROR MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost""my_user""my_password""world");

$result $mysqli->query("SELECT Name, CountryCode FROM City ORDER BY ID LIMIT 3");

$rows $result->fetch_all(MYSQLI_ASSOC);
foreach (
$rows as $row) {
    
printf("%s (%s)\n"$row["Name"], $row["CountryCode"]);
}

Prozeduraler Stil

<?php

mysqli_report
(MYSQLI_REPORT_ERROR MYSQLI_REPORT_STRICT);
$mysqli mysqli_connect("localhost""my_user""my_password""world");

$result mysqli_query($mysqli"SELECT Name, CountryCode FROM City ORDER BY ID LIMIT 3");

$rows mysqli_fetch_all($resultMYSQLI_ASSOC);
foreach (
$rows as $row) {
    
printf("%s (%s)\n"$row["Name"], $row["CountryCode"]);
}

Die obigen Bespiele erzeugen folgende Ausgabe:

Kabul (AFG)
Qandahar (AFG)
Herat (AFG)

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Ich bin am verrückt werden - Session und neue Webseite

That is an extremely bright idea

Geschrieben von EssaMattou am 02.05.2024 09:34:57
Forum: SQL / Datenbanken
"Why adore HTMX over JavaScript?"

What specific features or aspects of HTMX, a library designed to enhance interactions in web applications, appeal to users who have a strong affin ...

Geschrieben von WartanThamar am 02.05.2024 06:53:08
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
What defines Laravel's developer community?

What factors contribute to the perceived happiness within the Laravel developer community, and how does this compare to other developer communitie ...

Geschrieben von BakhamMamodar am 01.05.2024 10:45:23
Forum: PHP Developer Forum