<!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>Executes a stored procedure on a MS SQL server database</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mssql-data-seek.html">mssql_data_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mssql-fetch-array.html">mssql_fetch_array</a></div> <div class="up"><a href="ref.mssql.html">Mssql Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.mssql-execute" class="refentry"> <div class="refnamediv"> <h1 class="refname">mssql_execute</h1> <p class="verinfo">(PHP 4 >= 4.0.7, PHP 5, PECL odbtp >= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_execute</span> — <span class="dc-title">Executes a stored procedure on a MS SQL server database</span></p> </div> <div class="refsect1 description" id="refsect1-function.mssql-execute-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>mssql_execute</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stmt</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$skip_results</code><span class="initializer"> = false</span></span> ] )</div> <p class="para rdfs-comment"> Executes a stored procedure on a MS SQL server database </p> </div> <div class="refsect1 parameters" id="refsect1-function.mssql-execute-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"> Statement handle obtained with <span class="function"><a href="function.mssql-init.html" class="function">mssql_init()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">skip_results</code></em></span> <dd> <p class="para"> Whenever to skip the results or not. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples" id="refsect1-function.mssql-execute-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-1526"> <p><strong>Example #1 <span class="function"><strong>mssql_execute()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Create a new statement<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_init</span><span style="color: #007700">(</span><span style="color: #DD0000">'NewBlogEntry'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Some data strings<br /></span><span style="color: #0000BB">$title </span><span style="color: #007700">= </span><span style="color: #DD0000">'Test of blogging system'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$content </span><span style="color: #007700">= </span><span style="color: #DD0000">'If you can read this, then the new system is compatible with MSSQL'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Bind values<br /></span><span style="color: #0000BB">mssql_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #DD0000">'@author'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Felipe Pena'</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLVARCHAR</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">60</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #DD0000">'@date'</span><span style="color: #007700">, </span><span style="color: #DD0000">'08/10/2008'</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLVARCHAR</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #DD0000">'@title'</span><span style="color: #007700">, </span><span style="color: #0000BB">$title</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLVARCHAR</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">60</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #DD0000">'@content'</span><span style="color: #007700">, </span><span style="color: #0000BB">$content</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLTEXT</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Execute the statement<br /></span><span style="color: #0000BB">mssql_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// And we can free it like so:<br /></span><span style="color: #0000BB">mssql_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.mssql-execute-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If the stored procedure returns parameters or a return value these will be available after the call to <span class="function"><strong>mssql_execute()</strong></span> unless the stored procedure returns more than one result set. In that case use <span class="function"><a href="function.mssql-next-result.html" class="function">mssql_next_result()</a></span> to shift through the results. When the last result has been processed the output parameters and return values will be available. </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.mssql-execute-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mssql-bind.html" class="function" rel="rdfs-seeAlso">mssql_bind()</a> - Adds a parameter to a stored procedure or a remote stored procedure</span></li> <li class="member"> <span class="function"><a href="function.mssql-free-statement.html" class="function" rel="rdfs-seeAlso">mssql_free_statement()</a> - Free statement memory</span></li> <li class="member"> <span class="function"><a href="function.mssql-init.html" class="function" rel="rdfs-seeAlso">mssql_init()</a> - Initializes a stored procedure or a remote stored procedure</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.mssql-data-seek.html">mssql_data_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mssql-fetch-array.html">mssql_fetch_array</a></div> <div class="up"><a href="ref.mssql.html">Mssql Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>