array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.oci-fetch-assoc.php', 1 => 'oci_fetch_assoc', ), 'up' => array ( 0 => 'ref.oci8.php', 1 => 'Fonctions OCI8', ), 'prev' => array ( 0 => 'function.oci-fetch-array.php', 1 => 'oci_fetch_array', ), 'next' => array ( 0 => 'function.oci-fetch-object.php', 1 => 'oci_fetch_object', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/oci8/functions/oci-fetch-assoc.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)
oci_fetch_assoc — Lit une ligne d'un résultat sous forme de tableau associatif
Retourne un tableau associatif contenant la prochaine ligne de résultat d'une requête.
Chaque élément du tableau correspond à une colonne de la ligne. Cette fonction
est appelé typiquement dans une boucle tant qu'elle ne retourne pas false
, indiquant
qu'il n'y a plus de ligne de disponible.
oci_fetch_assoc() est identique à la fonction
oci_fetch_array() et le mode
OCI_ASSOC
+ OCI_RETURN_NULLS
.
statement
Un identifiant de requête OCI8
créé par la fonction oci_parse() et exécuté par la fonction
oci_execute(), ou un identifiant de requête REF
CURSOR
.
Retourne un tableau associatif ou false
s'il n'y a plus de ligne de diponible
pour la requête statement
.
Exemple #1 Exemple avec oci_fetch_assoc()
<?php
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT department_id, department_name FROM departments');
oci_execute($stid);
while (($row = oci_fetch_assoc($stid)) != false) {
echo $row['DEPARTMENT_ID'] . " " . $row['DEPARTMENT_NAME'] . "<br>\n";
}
oci_free_statement($stid);
oci_close($conn);
?>
Note:
Voir oci_fetch_array() pour plus d'exemples sur la récupération de lignes.