<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="snmp.get" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>SNMP::get</refname>
  <refpurpose>Fetch an <acronym>SNMP</acronym> object</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;

  <methodsynopsis role="SNMP">
   <modifier>public</modifier> <type>mixed</type><methodname>SNMP::get</methodname>
   <methodparam><type class="union"><type>array</type><type>string</type></type><parameter>objectId</parameter></methodparam>
   <methodparam choice="opt"><type>bool</type><parameter>preserveKeys</parameter><initializer>&false;</initializer></methodparam>
  </methodsynopsis>
  <para>
   Fetch an <acronym>SNMP</acronym> object specified in
   <parameter>objectId</parameter> using GET query.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
  If <parameter>objectId</parameter> is a string, then <methodname>SNMP::get</methodname>
  will return <acronym>SNMP</acronym> object as string. If
  <parameter>objectId</parameter> is a array, all requested <acronym>SNMP</acronym>
  objects will be returned as associative array of the <acronym>SNMP</acronym> object ids and their
  values. 
  </para>
  <para>
  <variablelist>
   <varlistentry>
    <term><parameter>objectId</parameter></term>
    <listitem>
     <para>
      The <acronym>SNMP</acronym> object (OID) or objects
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>preserveKeys</parameter></term>
    <listitem>
     <para>
      When <parameter>objectId</parameter> is a array and
      <parameter>preserveKeys</parameter> set to &true; keys in results
      will be taken exactly as in <parameter>objectId</parameter>,
      otherwise <varname>SNMP::oid_output_format</varname> property is used to determinate
      the form of keys.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns <acronym>SNMP</acronym> objects requested as string or array
   depending on <parameter>objectId</parameter> type or &false; on error.
  </para>
 </refsect1>

 &snmp.methods.exceptions_enable.refsect;

 <refsect1 role="examples">
  &reftitle.examples;
  <example xml:id="snmp.get.example.singleoid">
   <title>Single <acronym>SNMP</acronym> object</title>
   <para>
     Single <acronym>SNMP</acronym> object may be requested in two ways: as
     string resulting string return value or as single-element array with
     associative array as output.
   </para>
   <programlisting role="php">
<![CDATA[
<?php
  $session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
  $sysdescr = $session->get("sysDescr.0");
  echo "$sysdescr\n";
  $sysdescr = $session->get(array("sysDescr.0"));
  print_r($sysdescr);
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
STRING: Test server
Array
(
    [SNMPv2-MIB::sysDescr.0] => STRING: Test server
)
]]>
   </screen>
  </example>
  <example xml:id="snmp.get.example.oidarray">
   <title>Multiple <acronym>SNMP</acronym> objects</title>
   <programlisting role="php">
<![CDATA[
  $session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
  $results = $session->get(array("sysDescr.0", "sysName.0"));
  print_r($results);
  $session->close();
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
Array
(
    [SNMPv2-MIB::sysDescr.0] => STRING: Test server
    [SNMPv2-MIB::sysName.0] => STRING: myhost.nodomain
)
]]>
   </screen>
  </example>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member><methodname>SNMP::getErrno</methodname></member>
   <member><methodname>SNMP::getError</methodname></member>
  </simplelist>
 </refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
