mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-17 21:16:57 +08:00
204 lines
11 KiB
HTML
204 lines
11 KiB
HTML
<!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>Adds a parameter to a stored procedure or a remote stored procedure</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.mssql-bind" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">mssql_bind</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.0.7, PHP 5, PECL odbtp >= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_bind</span> — <span class="dc-title">Adds a parameter to a stored procedure or a remote stored procedure</span></p>
|
||
|
||
</div>
|
||
|
||
<div id="function.mssql-bind-refsynopsisdiv">
|
||
<div class="warning"><strong class="warning">Warning</strong>
|
||
|
||
<p class="para">
|
||
This function was <em class="emphasis">REMOVED</em> in PHP 7.0.0.
|
||
</p>
|
||
<p class="para">
|
||
Alternatives to this function include:
|
||
</p>
|
||
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="pdostatement.bindparam.html" class="function">PDOStatement::bindParam()</a></span></li>
|
||
<li class="member"><span class="function"><a href="pdostatement.bindvalue.html" class="function">PDOStatement::bindValue()</a></span></li>
|
||
<li class="member"><span class="function"><a href="sqlsrv_prepare.html" class="function">sqlsrv_prepare()</a></span></li>
|
||
<li class="member"><span class="function"><a href="odbc_prepare.html" class="function">odbc_prepare()</a></span></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.mssql-bind-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>mssql_bind</strong></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stmt</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$param_name</code></span>
|
||
, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter reference">&$var</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code></span>
|
||
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$is_output</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
||
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$is_null</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$maxlen</code><span class="initializer"> = -1</span></span>
|
||
]]] ) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
Binds a parameter to a stored procedure or a remote stored procedure.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.mssql-bind-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">stmt</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Statement resource, obtained with <span class="function"><a href="mssql_init.html" class="function">mssql_init()</a></span>.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">param_name</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
The parameter name, as a string.
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
You have to include the <em>@</em> character, like in the
|
||
T-SQL syntax. See the explanation included in
|
||
<span class="function"><a href="mssql_execute.html" class="function">mssql_execute()</a></span>.
|
||
</p>
|
||
</p></blockquote>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">var</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
The PHP variable you'll bind the MSSQL parameter to. It is passed by
|
||
reference, to retrieve OUTPUT and RETVAL values after
|
||
the procedure execution.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">type</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
One of: <strong><code>SQLTEXT</code></strong>,
|
||
<strong><code>SQLVARCHAR</code></strong>, <strong><code>SQLCHAR</code></strong>,
|
||
<strong><code>SQLINT1</code></strong>, <strong><code>SQLINT2</code></strong>,
|
||
<strong><code>SQLINT4</code></strong>, <strong><code>SQLBIT</code></strong>,
|
||
<strong><code>SQLFLT4</code></strong>, <strong><code>SQLFLT8</code></strong>,
|
||
<strong><code>SQLFLTN</code></strong>.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">is_output</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Whether the value is an OUTPUT parameter or not. If it's an OUTPUT
|
||
parameter and you don't mention it, it will be treated as a normal
|
||
input parameter and no error will be thrown.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">is_null</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Whether the parameter is <strong><code>NULL</code></strong> or not. Passing the <strong><code>NULL</code></strong> value as
|
||
<code class="parameter">var</code> will not do the job.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">maxlen</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Used with char/varchar values. You have to indicate the length of the
|
||
data so if the parameter is a varchar(50), the type must be
|
||
<strong><code>SQLVARCHAR</code></strong> and this value <em>50</em>.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.mssql-bind-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.mssql-bind-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-1746">
|
||
<p><strong>Example #1 <span class="function"><strong>mssql_bind()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Connect to MSSQL and select the database<br /></span><span style="color: #0000BB">mssql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'KALLESPC\SQLEXPRESS'</span><span style="color: #007700">, </span><span style="color: #DD0000">'sa'</span><span style="color: #007700">, </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">);<br /><br /></span><span style="color: #FF8000">// Create a new stored prodecure<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">'NewUserRecord'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Bind the field names<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">'@username'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Kalle'</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">'@name'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Kalle'</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">'@age'</span><span style="color: #007700">, </span><span style="color: #0000BB">19</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLINT1</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">3</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Execute<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">// Free statement<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>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.mssql-bind-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="mssql_execute.html" class="function" rel="rdfs-seeAlso">mssql_execute()</a> - Executes a stored procedure on a MS SQL server database</span></li>
|
||
<li class="member"><span class="function"><a href="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="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></div></div></body></html> |