cvs: peardoc /en/package/networking/net-ldap fetching.xml

From: Date: Tue, 04 Mar 2008 13:20:13 +0000
Subject: cvs: peardoc /en/package/networking/net-ldap fetching.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10556@lists.php.net to get a copy of this message
beni Tue Mar 4 13:20:13 2008 UTC Modified files: /peardoc/en/package/networking/net-ldap fetching.xml Log: * Included SPL foreach example http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap/fetching.xml?r1=1.4&r2=1.5&diff_format=u Index: peardoc/en/package/networking/net-ldap/fetching.xml diff -u peardoc/en/package/networking/net-ldap/fetching.xml:1.4 peardoc/en/package/networking/net-ldap/fetching.xml:1.5 --- peardoc/en/package/networking/net-ldap/fetching.xml:1.4 Wed Jan 9 23:05:06 2008 +++ peardoc/en/package/networking/net-ldap/fetching.xml Tue Mar 4 13:20:12 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="package.networking.net-ldap.fetching"> <refnamediv> <refname>Fetching entries</refname> @@ -10,7 +10,7 @@ <title>Retrieving entries directly</title> <para> - You can retrieve directory entries in two ways, either directly or from a performed search request. + You can retrieve directory entries in several ways, either directly or from a performed search request. If you want to fetch an entry directly, you need to know its absolute distinguished name (DN). To directly fetch an known entry from the directory server, you use @@ -52,8 +52,8 @@ you access the entries of a search result through the <classname>Net_LDAP_Search</classname>-object resulting from <classname>Net_LDAP</classname>'s <function>search</function> method. Each of the following methods return a <classname>Net_LDAP_Error</classname>-object if something goes wrong, so - remember to test for errors! - You have several ways to read the entries: + remember to test for errors! + You have several ways to read the entries: <table> <title>Possible ways to fetch entries</title> <tgroup cols="2"> @@ -148,6 +148,30 @@ </example> </refsect1> + + <refsect1> + <title>Retrieving entries via iteration (foreach)</title> + + <para> + Since Net_LDAP 1.2.0 you are able to use PHPs Standard Library (SPL) to iterate over + search results. This is done easily by just using the <classname>Net_LDAP_Search</classname> + search result object inside an foreach loop similar to an array. + You may optionally retrieve the DN of each entry by the same mechanism you use to + retrieve the key of an associative array. + </para> + + <example> + <title>Fetching entries via foreach()</title> + <programlisting role="php"><![CDATA[ +foreach ($search as $dn => $entry) { + // do something: + $sn = $entry->getValue('sn', 'single'); + echo "Fetched DN: $dn; Surname: $sn"; +} +]]></programlisting> + </example> + + </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables:

« previous php.pear.doc (#10556) next »