Doc #19652 [Opn->Fbk]: Retrieving entries via iteration (foreach) incorrect description
| From: | beni@php.net | Date: | Thu, 03 Jan 2013 09:00:45 +0000 |
| Subject: | Doc #19652 [Opn->Fbk]: Retrieving entries via iteration (foreach) incorrect description | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-9447@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19652&edit=1
ID: 19652
Updated by: beni@php.net
Reported By: sunmoon51 at gazeta dot pl
Summary: Retrieving entries via iteration (foreach) incorrect
description
-Status: Open
+Status: Feedback
Type: Documentation Problem
Package: Net_LDAP2
Operating System: Solaris
PHP Version: 5.3.17
Roadmap Versions:
New Comment:
-Status: Open
+Status: Feedback
Hi there,
what exactly is wrong with the current code example?
Does the ($search as $dn => $entry) part no longer work?
In my opinion the current documentation is correct and comprehensive...
One of the advantages of the SPL is that you can do foreach on objects
like you do on an array, including to be able to get some sort of unique
identifier like in a hash (here it is the DN of the entry).
Your example lacks this opportunity.
Previous Comments:
------------------------------------------------------------------------
[2012-10-14 20:41:52] mhg
Description:
------------
Retrieving entries via iteration (foreach) description is incorrect.
Please note $entries is an array of entry objects. Therefore the
description should read:
Retrieving entries via iteration (foreach)
Since Net_LDAP2 you are able to use PHPs Standard Library (SPL) to
iterate over search results. This is done easily by just using the
Net_LDAP2_Entry object inside an foreach loop similar to an array. You
may optionally retrieve the DN of each entry.
Fetching entries via foreach()
<?php
$entries = $search->entries();
foreach ($entries as $value) {
$dn = $value->dn();
$sn = $value->getValue('sn', 'single');
echo "Fetched DN: $dn; Surname: $sn";
}
?>
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19652&edit=1