downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.mssql-pconnect.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.mssql.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.mssql-pconnect.php',
   
1 => 'mssql_pconnect',
  ),
 
'up' =>
  array (
   
0 => 'ref.mssql.php',
   
1 => 'Mssql Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.mssql-num-rows.php',
   
1 => 'mssql_num_rows',
  ),
 
'next' =>
  array (
   
0 => 'function.mssql-query.php',
   
1 => 'mssql_query',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.mssql-pconnect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mssql_pconnect</h1>
  <p class="verinfo">(PHP 4, PHP 5, PECL odbtp &gt;= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_pconnect</span> &mdash; <span class="dc-title">Open persistent MS SQL connection</span></p>

 </div>
 
 <a name="function.mssql-pconnect.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><b>mssql_pconnect</b></span>
    ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$servername</tt></span>
   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$username</tt></span>
   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$password</tt></span>
   [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$new_link</tt></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   <b>mssql_pconnect()</b> acts very much like
   <a href="function.mssql-connect.php" class="function">mssql_connect()</a> with two major differences.
  </p>
  <p class="para">
   First, when connecting, the function would first try to find a
   (persistent) link that&#039;s already open with the same host,
   username and password.  If one is found, an identifier for it
   will be returned instead of opening a new connection.
  </p>
  <p class="para">
   Second, the connection to the SQL server will not be closed when
   the execution of the script ends.  Instead, the link will remain
   open for future use (<a href="function.mssql-close.php" class="function">mssql_close()</a> will not
   close links established by <b>mssql_pconnect()</b>).
  </p>
  <p class="para">
   This type of links is therefore called &#039;persistent&#039;.
  </p>
 </div>


 <a name="function.mssql-pconnect.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">servername</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The MS SQL server. It can also include a port number. e.g.
       <i>hostname:port</i>.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">username</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The username.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">password</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The password.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">new_link</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If a second call is made to <b>mssql_pconnect()</b> with
       the same arguments, no new link will be established, but instead, the
       link identifier of the already opened link will be returned. This
       parameter modifies this behavior and makes
       <b>mssql_pconnect()</b> always open a new link, even if
       <b>mssql_pconnect()</b> was called before with the same
       parameters.
      </p>
     </dd>

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


 <a name="function.mssql-pconnect.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a positive MS SQL persistent link identifier on success, or
   <b><tt class="constant">FALSE</tt></b> on error.
  </p>
 </div>


 <a name="function.mssql-pconnect.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>mssql_pconnect()</b> using the <i><tt class="parameter">new_link</tt></i>
 parameter</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Connect&nbsp;to&nbsp;the&nbsp;database&nbsp;server<br /></span><span style="color: #0000BB">$link1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mssql_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">'MANGO\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sa'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;new&nbsp;link<br /></span><span style="color: #0000BB">$link2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mssql_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">'MANGO\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sa'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'random'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites