<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pdo-sqlsrv.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'ref.pdo-sqlsrv.connection.php',
    1 => 'PDO_SQLSRV DSN',
    2 => 'Connecting to MS SQL Server and SQL Azure databases',
  ),
  'up' => 
  array (
    0 => 'ref.pdo-sqlsrv.php',
    1 => 'MS SQL Server PDO Driver',
  ),
  'prev' => 
  array (
    0 => 'ref.pdo-sqlsrv.php',
    1 => 'MS SQL Server PDO Driver',
  ),
  'next' => 
  array (
    0 => 'ref.pdo-oci.php',
    1 => 'Oracle PDO Driver',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo_sqlsrv/reference.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ref.pdo-sqlsrv.connection" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">PDO_SQLSRV DSN</h1>
    <p class="verinfo">(PECL pdo_sqlsrv &gt;= 2.0.1)</p><p class="refpurpose"><span class="refname">PDO_SQLSRV DSN</span> &mdash; <span class="dc-title">Connecting to MS SQL Server and SQL Azure databases</span></p>

   </div>

   <div class="refsect1 description" id="refsect1-ref.pdo-sqlsrv.connection-description">
    <h3 class="title">Опис</h3>
    <p class="para">
     The PDO_SQLSRV Data Source Name (DSN) is composed of the following elements:
     <dl>
      
       <dt>DSN prefix</dt>
       <dd>
        <p class="para">
        The DSN prefix is <strong class="userinput"><code>sqlsrv:</code></strong>.
        </p>
       </dd>
      
      
       <dt><code class="literal">APP</code></dt>
       <dd>
        <p class="para">
         The application name used in tracing.
        </p>
       </dd>
      
      
       <dt><code class="literal">ConnectionPooling</code></dt>
       <dd>
        <p class="para">
         Specifies whether the connection is assigned from a connection pool
         (1 or <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>) or not (0 or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>).
        </p>
       </dd>
      
      
       <dt><code class="literal">Database</code></dt>
       <dd>
        <p class="para">
         The name of the database.
        </p>
       </dd>
      
      
       <dt><code class="literal">Encrypt</code></dt>
       <dd>
        <p class="para">
         Specifies whether the communication with SQL Server is encrypted
         (1 or <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>) or unencrypted (0 or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>).
        </p>
       </dd>
      
      
       <dt><code class="literal">Failover_Partner</code></dt>
       <dd>
        <p class="para">
         Specifies the server and instance of the database&#039;s mirror (if enabled
         and configured) to use when the primary server is unavailable.
        </p>
       </dd>
      
      
       <dt><code class="literal">LoginTimeout</code></dt>
       <dd>
        <p class="para">
         Specifies the number of seconds to wait before failing the connection attempt.
        </p>
       </dd>
      
      
       <dt><code class="literal">MultipleActiveResultSets</code></dt>
       <dd>
        <p class="para">
         Disables or explicitly enables support for multiple active Result sets (MARS).
        </p>
       </dd>
      
      
       <dt><code class="literal">QuotedId</code></dt>
       <dd>
        <p class="para">
         Specifies whether to use SQL-92 rules for quoted identifiers (1 or <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>)
         or to use legacy Transact-SQL rules (0 or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>).
        </p>
       </dd>
      
      
       <dt><code class="literal">Server</code></dt>
       <dd>
        <p class="para">
         The name of the database server.
        </p>
       </dd>
      
      
       <dt><code class="literal">TraceFile</code></dt>
       <dd>
        <p class="para">
         Specifies the path for the file used for trace data.
        </p>
       </dd>
      
      
       <dt><code class="literal">TraceOn</code></dt>
       <dd>
        <p class="para">
         Specifies whether ODBC tracing is enabled (1 or <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>) or disabled
         (0 or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>) for the connection being established.
        </p>
       </dd>
      
      
       <dt><code class="literal">TransactionIsolation</code></dt>
       <dd>
        <p class="para">
         Specifies the transaction isolation level. The accepted values for this
         option are PDO::SQLSRV_TXN_READ_UNCOMMITTED, PDO::SQLSRV_TXN_READ_COMMITTED,
         PDO::SQLSRV_TXN_REPEATABLE_READ, PDO::SQLSRV_TXN_SNAPSHOT, and
         PDO::SQLSRV_TXN_SERIALIZABLE.
        </p>
       </dd>
      
      
       <dt><code class="literal">TrustServerCertificate</code></dt>
       <dd>
        <p class="para">
         Specifies whether the client should trust (1 or <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>) or reject
         (0 or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>) a self-signed server certificate.
        </p>
       </dd>
      
      
       <dt><code class="literal">WSID</code></dt>
       <dd>
        <p class="para">
         Specifies the name of the computer for tracing.
        </p>
       </dd>
      
     </dl>
    </p>
   </div>


   <div class="refsect1 examples" id="refsect1-ref.pdo-sqlsrv.connection-examples">
    <h3 class="title">Приклади</h3>
    <p class="para">
     <div class="example" id="example-1">
      <p><strong>Приклад #1 PDO_SQLSRV DSN examples</strong></p>
      <div class="example-contents"><p>
       The following example shows how to connecto to a specified MS SQL Server database:
       <div class="example-contents">
<div class="cdata"><pre>
$c = new PDO(&quot;sqlsrv:Server=localhost;Database=testdb&quot;, &quot;UserName&quot;, &quot;Password&quot;);
</pre></div>
       </div>

       </p></div>
       <div class="example-contents"><p>
       The following example shows how to connect to a MS SQL Server database on
       a specified port:
       <div class="example-contents">
<div class="cdata"><pre>
$c = new PDO(&quot;sqlsrv:Server=localhost,1521;Database=testdb&quot;, &quot;UserName&quot;, &quot;Password&quot;);
</pre></div>
       </div>

      </p></div>
      <div class="example-contents"><p>
       The following example shows how to connecto to a SQL Azure database with
       server ID 12345abcde. Note that when you connect to SQL Azure with PDO,
       your username will be UserName@12345abcde (UserName@ServerId).
       <div class="example-contents">
<div class="cdata"><pre>
$c = new PDO(&quot;sqlsrv:Server=12345abcde.database.windows.net;Database=testdb&quot;, &quot;UserName@12345abcde&quot;, &quot;Password&quot;);
</pre></div>
       </div>

      </p></div>
     </div>
    </p>
   </div>

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