📄 function.db2-exec.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Executes an SQL statement directly</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.db2-escape-string.html">db2_escape_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-execute.html">db2_execute</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.db2-exec" class="refentry"> <div class="refnamediv"> <h1 class="refname">db2_exec</h1> <p class="verinfo">(PECL ibm_db2:1.0-1.6.2)</p><p class="refpurpose"><span class="refname">db2_exec</span> — <span class="dc-title"> Executes an SQL statement directly </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><b><b>db2_exec</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$connection</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$statement</tt></span> [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$options</tt></span> ] )</div> <p class="para rdfs-comment"> Executes an SQL statement directly. </p> <p class="para"> If you plan to interpolate PHP variables into the SQL statement, understand that this is one of the more common security exposures. Consider calling <a href="function.db2-prepare.html" class="function">db2_prepare()</a> to prepare an SQL statement with parameter markers for input values. Then you can call <a href="function.db2-execute.html" class="function">db2_execute()</a> to pass in the input values and avoid SQL injection attacks. </p> <p class="para"> If you plan to repeatedly issue the same SQL statement with different parameters, consider calling <a href="function.db2-prepare.html" class="function">db2_prepare()</a> and <a href="function.db2-execute.html" class="function">db2_execute()</a> to enable the database server to reuse its access plan and increase the efficiency of your database access. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">connection</tt></i></span> <dd> <p class="para"> A valid database connection resource variable as returned from <a href="function.db2-connect.html" class="function">db2_connect()</a> or <a href="function.db2-pconnect.html" class="function">db2_pconnect()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">statement</tt></i></span> <dd> <p class="para"> An SQL statement. The statement cannot contain any parameter markers. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">options</tt></i></span> <dd> <p class="para"> An associative array containing statement options. You can use this parameter to request a scrollable cursor on database servers that support this functionality. <dl> <dt> <br /><span class="term"><i><tt class="parameter">cursor</tt></i></span> <dd> <p class="para"> Passing the <i>DB2_FORWARD_ONLY</i> value requests a forward-only cursor for this SQL statement. This is the default type of cursor, and it is supported by all database servers. It is also much faster than a scrollable cursor. </p> <p class="para"> Passing the <i>DB2_SCROLLABLE</i> value requests a scrollable cursor for this SQL statement. This type of cursor enables you to fetch rows non-sequentially from the database server. However, it is only supported by DB2 servers, and is much slower than forward-only cursors. </p> </dd> </dt> </dl> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a statement resource if the SQL statement was issued successfully, or <b><tt>FALSE</tt></b> if the database failed to execute the SQL statement. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Creating a table with <b>db2_exec()</b></b></p> <div class="example-contents"><p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -