function.fbsql-query.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 176 行
HTML
176 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Send a FrontBase query</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.fbsql-pconnect.html">fbsql_pconnect</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.fbsql-read-blob.html">fbsql_read_blob</a></div> <div class="up"><a href="ref.fbsql.html">FrontBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.fbsql-query" class="refentry"> <div class="refnamediv"> <h1 class="refname">fbsql_query</h1> <p class="verinfo">(PHP 4 >= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">fbsql_query</span> — <span class="dc-title">Send a FrontBase query</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>fbsql_query</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$query</tt></span> [, <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$link_identifier</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$batch_size</tt></span> ]] )</div> <p class="para rdfs-comment"> Sends a <i><tt class="parameter">query</tt></i> to the currently active database on the server. </p> <p class="para"> If the query succeeds, you can call <a href="function.fbsql-num-rows.html" class="function">fbsql_num_rows()</a> to find out how many rows were returned for a SELECT statement or <a href="function.fbsql-affected-rows.html" class="function">fbsql_affected_rows()</a> to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">query</tt></i></span> <dd> <p class="para"> The SQL query to be executed. </p> <blockquote><p><b class="note">Note</b>: The query string shall always end with a semicolon. <br /> </p></blockquote> </dd> </dt> <dt><span class="term"><i><tt class="parameter">link_identifier</tt></i></span><dd><p class="para">A FrontBase link identifierreturned by <a href="function.fbsql-connect.html" class="function">fbsql_connect()</a> or <a href="function.fbsql-pconnect.html" class="function">fbsql_pconnect()</a>.</p><p class="para">If optional and not specified,the function will try to find an open link to the FrontBase server and if nosuch link is found it will try to create one as if <a href="function.fbsql-connect.html" class="function">fbsql_connect()</a> was called with no arguments</p></dd></dt> <dt> <span class="term"><i><tt class="parameter">batch_size</tt></i></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <b>fbsql_query()</b> returns <b><tt>TRUE</tt></b> (non-zero) or <b><tt>FALSE</tt></b> to indicate whether or not the query succeeded. A return value of <b><tt>TRUE</tt></b> means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. </p> <p class="para"> For SELECT statements, <b>fbsql_query()</b> returns a new result identifier that you can pass to <a href="function.fbsql-result.html" class="function">fbsql_result()</a>. </p> <p class="para"> <b>fbsql_query()</b> will also fail and return <b><tt>FALSE</tt></b> if you don't have permission to access the table(s) referenced by the query. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> The following query is syntactically invalid, so <b>fbsql_query()</b> fails and returns <b><tt>FALSE</tt></b>: <div class="example"> <p><b>Example #1 <b>fbsql_query()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">fbsql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT * WHERE 1=1"</span><span style="color: #007700">)<br /> or die (</span><span style="color: #DD0000">"Invalid query"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> The following query is semantically invalid if <i>my_col</i> is not a column in the table <i>my_tbl</i>, so <b>fbsql_query()</b> fails and returns <b><tt>FALSE</tt></b>: <div class="example"> <p><b>Example #2 <b>fbsql_query()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">fbsql_query </span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT my_col FROM my_tbl;"</span><span style="color: #007700">)<br /> or die (</span><span style="color: #DD0000">"Invalid query"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.fbsql-affected-rows.html" class="function" rel="rdfs-seeAlso">fbsql_affected_rows()</a></li> <li class="member"><a href="function.fbsql-db-query.html" class="function" rel="rdfs-seeAlso">fbsql_db_query()</a></li> <li class="member"><a href="function.fbsql-free-result.html" class="function" rel="rdfs-seeAlso">fbsql_free_result()</a></li> <li class="member"><a href="function.fbsql-result.html" class="function" rel="rdfs-seeAlso">fbsql_result()</a></li> <li class="member"><a href="function.fbsql-select-db.html" class="function" rel="rdfs-seeAlso">fbsql_select_db()</a></li> <li class="member"><a href="function.fbsql-connect.html" class="function" rel="rdfs-seeAlso">fbsql_connect()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.fbsql-pconnect.html">fbsql_pconnect</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.fbsql-read-blob.html">fbsql_read_blob</a></div> <div class="up"><a href="ref.fbsql.html">FrontBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?