Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5889

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Cancels a statement</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.sqlsrv-begin-transaction.html">sqlsrv_begin_transaction</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sqlsrv-client-info.html">sqlsrv_client_info</a></div>
 <div class="up"><a href="ref.sqlsrv.html">SQLSRV Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.sqlsrv-cancel" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlsrv_cancel</h1>
  <p class="verinfo">(No version information available, might only be in SVN)</p><p class="refpurpose"><span class="refname">sqlsrv_cancel</span> &mdash; <span class="dc-title">Cancels a statement</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.sqlsrv-cancel-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>sqlsrv_cancel</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stmt</code></span>
   )</div>

  <p class="para rdfs-comment">
   Cancels a statement. Any results associated with the statement that have not 
   been consumed are deleted. After  <span class="function"><strong>sqlsrv_cancel()</strong></span> has been 
   called, the specified statement can be re-executed if it was created with 
    <span class="function"><a href="function.sqlsrv-prepare.html" class="function">sqlsrv_prepare()</a></span>. Calling  <span class="function"><strong>sqlsrv_cancel()</strong></span> 
   is not necessary if all the results associated with the statement have been 
   consumed.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.sqlsrv-cancel-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">stmt</code></em></span>
     <dd>

      <p class="para">
       The statement resource to be cancelled.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.sqlsrv-cancel-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.sqlsrv-cancel-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2168">
    <p><strong>Example #1  <span class="function"><strong>sqlsrv_cancel()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$serverName&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"serverName\sqlexpress"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$connectionInfo&nbsp;</span><span style="color: #007700">=&nbsp;array(&nbsp;</span><span style="color: #DD0000">"Database"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"dbName"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UID"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"username"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"PWD"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_connect</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$serverName</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$connectionInfo</span><span style="color: #007700">);<br />if(&nbsp;</span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}<br /><br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;Sales&nbsp;FROM&nbsp;Table_1"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_prepare</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /><br />if(&nbsp;</span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}<br /><br />if(&nbsp;</span><span style="color: #0000BB">sqlsrv_execute</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}<br /><br /></span><span style="color: #0000BB">$salesTotal&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br />while(&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_fetch_array</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">))&nbsp;&amp;&amp;&nbsp;</span><span style="color: #0000BB">$salesTotal&nbsp;</span><span style="color: #007700">&lt;=</span><span style="color: #0000BB">100000</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$qty&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$price&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$salesTotal&nbsp;</span><span style="color: #007700">+=&nbsp;(&nbsp;</span><span style="color: #0000BB">$price&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">$qty</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$count</span><span style="color: #007700">++;<br />}<br /><br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$count</span><span style="color: #DD0000">&nbsp;sales&nbsp;accounted&nbsp;for&nbsp;the&nbsp;first&nbsp;$</span><span style="color: #0000BB">$salesTotal</span><span style="color: #DD0000">&nbsp;in&nbsp;revenue.&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Cancel&nbsp;the&nbsp;pending&nbsp;results.&nbsp;The&nbsp;statement&nbsp;can&nbsp;be&nbsp;reused.<br /></span><span style="color: #0000BB">sqlsrv_cancel</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.sqlsrv-cancel-notes">
  <h3 class="title">Notes</h3>
  <p class="para">
   The main difference between  <span class="function"><strong>sqlsrv_cancel()</strong></span> and 
    <span class="function"><a href="function.sqlsrv-free-stmt.html" class="function">sqlsrv_free_stmt()</a></span> is that a statement resource cancelled with 
    <span class="function"><strong>sqlsrv_cancel()</strong></span> can be re-executed if it was created with 
    <span class="function"><a href="function.sqlsrv-prepare.html" class="function">sqlsrv_prepare()</a></span>. A statement resource cancelled with 
    <span class="function"><strong>sqlsrv_free_statement()</strong></span> cannot be re-executed.
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.sqlsrv-cancel-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.sqlsrv-free-stmt.html" class="function" rel="rdfs-seeAlso">sqlsrv_free_stmt()</a> - Frees all resources for the specified statement</span></li>
    <li class="member"> <span class="function"><a href="function.sqlsrv-prepare.html" class="function" rel="rdfs-seeAlso">sqlsrv_prepare()</a> - Prepares a query for execution</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.sqlsrv-begin-transaction.html">sqlsrv_begin_transaction</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sqlsrv-client-info.html">sqlsrv_client_info</a></div>
 <div class="up"><a href="ref.sqlsrv.html">SQLSRV Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>