<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-session.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-session.getserver.php',
    1 => 'MongoDB\\Driver\\Session::getServer',
    2 => 'Returns the server to which this session is pinned',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-session.php',
    1 => 'MongoDB\\Driver\\Session',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-session.getoperationtime.php',
    1 => 'MongoDB\\Driver\\Session::getOperationTime',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-session.gettransactionoptions.php',
    1 => 'MongoDB\\Driver\\Session::getTransactionOptions',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/session/getserver.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-session.getserver" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Session::getServer</h1>
  <p class="verinfo">(mongodb &gt;=1.6.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Session::getServer</span> &mdash; <span class="dc-title">Returns the server to which this session is pinned</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-session.getserver-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Session::getServer</strong></span>(): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.mongodb-driver-server.php" class="type MongoDB\Driver\Server">MongoDB\Driver\Server</a></span></span></div>

  <p class="simpara">
   Returns the <span class="classname"><a href="class.mongodb-driver-server.php" class="classname">MongoDB\Driver\Server</a></span> to which this
   session is pinned. If the session is not pinned to a server, <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> will be
   returned.
  </p>
  <p class="simpara">
   Session pinning is primarily used for sharded transactions, as all commands
   within a sharded transaction must be sent to the same mongos instance. This
   method is intended to be used by libraries built atop the extension to allow
   use of a pinned server instead of invoking server selection.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-session.getserver-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-session.getserver-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns the <span class="classname"><a href="class.mongodb-driver-server.php" class="classname">MongoDB\Driver\Server</a></span> to which this
   session is pinned, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> if the session is not pinned to any server.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-session.getserver-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <ul class="simplelist">
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>