<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >mSQL Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="msession_unlock" HREF="function.msession-unlock.html"><LINK REL="NEXT" TITLE="msql_affected_rows" HREF="function.msql-affected-rows.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.msession-unlock.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.msql-affected-rows.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.msql" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XCV. mSQL Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN129647" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.intro" >简介</A ></H1 ><P > These functions allow you to access mSQL database servers. More information about mSQL can be found at <A HREF="http://www.hughes.com.au/" TARGET="_top" >http://www.hughes.com.au/</A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.installation" >安装</A ></H1 ><P > In order to have these functions available, you must compile PHP with msql support by using the <CODE CLASS="option" >--with-msql[=DIR]</CODE > option. DIR is the mSQL base install directory, defaults to <TT CLASS="filename" >/usr/local/msql3</TT >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note to Win32 Users: </B > In order for this extension to work, there are <ACRONYM CLASS="acronym" >DLL</ACRONYM > files that must be available to the Windows system <TT CLASS="literal" >PATH</TT >. See the <ACRONYM CLASS="acronym" >FAQ</ACRONYM > titled "<A HREF="faq.installation.html#faq.installation.addtopath" >How do I add my PHP directory to the PATH on Windows</A >" for information on how to do this. Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the systems <TT CLASS="literal" >PATH</TT >), it is not recommended. <SPAN CLASS="emphasis" ><I CLASS="emphasis" >This extension requires the following files to be in the <TT CLASS="literal" >PATH</TT >:</I ></SPAN > <TT CLASS="filename" >msql.dll</TT > </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.configuration" >运行时配置</A ></H1 ><P >这些函数的行为受 <TT CLASS="filename" >php.ini</TT > 的影响。</P ><P > <DIV CLASS="table" ><A NAME="AEN129673" ></A ><P ><B >表 1. mSQL configuration options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Default</TH ><TH >Changeable</TH ><TH >Changelog</TH ></TR ></THEAD ><TBODY ><TR ><TD >msql.allow_persistent</TD ><TD >"1"</TD ><TD >PHP_INI_ALL</TD ><TD > </TD ></TR ><TR ><TD >msql.max_persistent</TD ><TD >"-1"</TD ><TD >PHP_INI_ALL</TD ><TD > </TD ></TR ><TR ><TD >msql.max_links</TD ><TD >"-1"</TD ><TD >PHP_INI_ALL</TD ><TD > </TD ></TR ></TBODY ></TABLE ></DIV > 有关 PHP_INI_* 常量进一步的细节与定义参见<A HREF="ini.html" >附录 H</A >。 </P ><P >以下是配置选项的简要解释。</P ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><A NAME="ini.msql.allow-persistent" ></A ><CODE CLASS="parameter" >msql.allow_persistent</CODE > <A HREF="language.types.boolean.html" ><B CLASS="type" >boolean</B ></A ></DT ><DD ><P > Whether to allow persistent mSQL connections. </P ></DD ><DT ><A NAME="ini.msql.max-persistent" ></A ><CODE CLASS="parameter" >msql.max_persistent</CODE > <A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></DT ><DD ><P > The maximum number of persistent mSQL connections per process. </P ></DD ><DT ><A NAME="ini.msql.max-links" ></A ><CODE CLASS="parameter" >msql.max_links</CODE > <A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></DT ><DD ><P > The maximum number of mSQL connections per process, including persistent connections. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.resources" >资源类型</A ></H1 ><P > There are two resource types used in the mSQL module. The first one is the link identifier for a database connection, the second a resource which holds the result of a query. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.constants" >预定义常量</A ></H1 ><P >以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。</P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >MSQL_ASSOC</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >MSQL_NUM</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >MSQL_BOTH</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.examples" >范例</A ></H1 ><P > This simple example shows how to connect, execute a query, print resulting rows and disconnect from a mSQL database. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN129748" ></A ><P ><B >例 1. mSQL usage example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">/* Connecting, selecting database */<br /></font><font color="#0000BB">$link </font><font color="#007700">= </font><font color="#0000BB">msql_connect</font><font color="#007700">(</font><font color="#DD0000">'localhost'</font><font color="#007700">, </font><font color="#DD0000">'username'</font><font color="#007700">, </font><font color="#DD0000">'password'</font><font color="#007700">)<br /> or die(</font><font color="#DD0000">'Could not connect : ' </font><font color="#007700">. </font><font color="#0000BB">msql_error</font><font color="#007700">(</font><font color="#0000BB">$link</font><font color="#007700">));<br /><br /></font><font color="#0000BB">msql_select_db</font><font color="#007700">(</font><font color="#DD0000">'database'</font><font color="#007700">, </font><font color="#0000BB">$link</font><font color="#007700">)<br /> or die(</font><font color="#DD0000">'Could not select database'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">/* Issue SQL query */<br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'SELECT * FROM my_table'</font><font color="#007700">;<br /></font><font color="#0000BB">$result </font><font color="#007700">= </font><font color="#0000BB">msql_query</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">, </font><font color="#0000BB">$link</font><font color="#007700">) or die(</font><font color="#DD0000">'Query failed : ' </font><font color="#007700">. </font><font color="#0000BB">msql_error</font><font color="#007700">(</font><font color="#0000BB">$link</font><font color="#007700">));<br /><br /></font><font color="#FF8000">/* Printing results in HTML */<br /></font><font color="#007700">echo </font><font color="#DD0000">"<table>\n"</font><font color="#007700">;<br />while (</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">msql_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">, </font><font color="#0000BB">MSQL_ASSOC</font><font color="#007700">)) {<br /> echo </font><font color="#DD0000">"\t<tr>\n"</font><font color="#007700">;<br /> foreach (</font><font color="#0000BB">$row </font><font color="#007700">as </font><font color="#0000BB">$col_value</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"</font><font color="#007700">\t\t</font><font color="#DD0000"><td>$col_value</td></font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br /> }<br /> echo </font><font color="#DD0000">"\t</tr>\n"</font><font color="#007700">;<br />}<br />echo </font><font color="#DD0000">"</table>\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">/* Free result set */<br /></font><font color="#0000BB">msql_free_result</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">);<br /><br /></font><font color="#FF8000">/* Close connection */<br /></font><font color="#0000BB">msql_close</font><font color="#007700">(</font><font color="#0000BB">$link</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.msql-affected-rows.html" >msql_affected_rows</A > -- Returns number of affected rows</DT ><DT ><A HREF="function.msql-close.html" >msql_close</A > -- Close mSQL connection</DT ><DT ><A HREF="function.msql-connect.html" >msql_connect</A > -- Open mSQL connection</DT ><DT ><A HREF="function.msql-create-db.html" >msql_create_db</A > -- Create mSQL database</DT ><DT ><A HREF="function.msql-createdb.html" >msql_createdb</A > -- 别名 <A HREF="function.msql-create-db.html" ><B CLASS="function" >msql_create_db()</B ></A ></DT ><DT ><A HREF="function.msql-data-seek.html" >msql_data_seek</A > -- Move internal row pointer</DT ><DT ><A HREF="function.msql-db-query.html" >msql_db_query</A > -- Send mSQL query</DT ><DT ><A HREF="function.msql-dbname.html" >msql_dbname</A > -- 别名 <A HREF="function.msql-result.html" ><B CLASS="function" >msql_result()</B ></A ></DT ><DT ><A HREF="function.msql-drop-db.html" >msql_drop_db</A > -- Drop (delete) mSQL database</DT ><DT ><A HREF="function.msql-error.html" >msql_error</A > -- Returns error message of last msql call</DT ><DT ><A HREF="function.msql-fetch-array.html" >msql_fetch_array</A > -- Fetch row as array</DT ><DT ><A HREF="function.msql-fetch-field.html" >msql_fetch_field</A > -- Get field information</DT ><DT ><A HREF="function.msql-fetch-object.html" >msql_fetch_object</A > -- Fetch row as object</DT ><DT ><A HREF="function.msql-fetch-row.html" >msql_fetch_row</A > -- Get row as enumerated array</DT ><DT ><A HREF="function.msql-field-flags.html" >msql_field_flags</A > -- Get field flags</DT ><DT ><A HREF="function.msql-field-len.html" >msql_field_len</A > -- Get field length</DT ><DT ><A HREF="function.msql-field-name.html" >msql_field_name</A > -- Get the name of the specified field in a result</DT ><DT ><A HREF="function.msql-field-seek.html" >msql_field_seek</A > -- Set field offset</DT ><DT ><A HREF="function.msql-field-table.html" >msql_field_table</A > -- Get table name for field</DT ><DT ><A HREF="function.msql-field-type.html" >msql_field_type</A > -- Get field type</DT ><DT ><A HREF="function.msql-fieldflags.html" >msql_fieldflags</A > -- Alias of <A HREF="function.msql-field-flags.html" ><B CLASS="function" >msql_field_flags()</B ></A ></DT ><DT ><A HREF="function.msql-fieldlen.html" >msql_fieldlen</A > -- Alias of <A HREF="function.msql-field-len.html" ><B CLASS="function" >msql_field_len()</B ></A ></DT ><DT ><A HREF="function.msql-fieldname.html" >msql_fieldname</A > -- Alias of <A HREF="function.msql-field-name.html" ><B CLASS="function" >msql_field_name()</B ></A ></DT ><DT ><A HREF="function.msql-fieldtable.html" >msql_fieldtable</A > -- Alias of <A HREF="function.msql-field-table.html" ><B CLASS="function" >msql_field_table()</B ></A ></DT ><DT ><A HREF="function.msql-fieldtype.html" >msql_fieldtype</A > -- Alias of <A HREF="function.msql-field-type.html" ><B CLASS="function" >msql_field_type()</B ></A ></DT ><DT ><A HREF="function.msql-free-result.html" >msql_free_result</A > -- Free result memory</DT ><DT ><A HREF="function.msql-list-dbs.html" >msql_list_dbs</A > -- List mSQL databases on server</DT ><DT ><A HREF="function.msql-list-fields.html" >msql_list_fields</A > -- List result fields</DT ><DT ><A HREF="function.msql-list-tables.html" >msql_list_tables</A > -- List tables in an mSQL database</DT ><DT ><A HREF="function.msql-num-fields.html" >msql_num_fields</A > -- Get number of fields in result</DT ><DT ><A HREF="function.msql-num-rows.html" >msql_num_rows</A > -- Get number of rows in result</DT ><DT ><A HREF="function.msql-numfields.html" >msql_numfields</A > -- Alias of <A HREF="function.msql-num-fields.html" ><B CLASS="function" >msql_num_fields()</B ></A ></DT ><DT ><A HREF="function.msql-numrows.html" >msql_numrows</A > -- Alias of <A HREF="function.msql-num-rows.html" ><B CLASS="function" >msql_num_rows()</B ></A ></DT ><DT ><A HREF="function.msql-pconnect.html" >msql_pconnect</A > -- Open persistent mSQL connection</DT ><DT ><A HREF="function.msql-query.html" >msql_query</A > -- Send mSQL query</DT ><DT ><A HREF="function.msql-regcase.html" >msql_regcase</A > -- Alias of <A HREF="function.sql-regcase.html" ><B CLASS="function" >sql_regcase()</B ></A ></DT ><DT ><A HREF="function.msql-result.html" >msql_result</A > -- Get result data</DT ><DT ><A HREF="function.msql-select-db.html" >msql_select_db</A > -- Select mSQL database</DT ><DT ><A HREF="function.msql-tablename.html" >msql_tablename</A > -- Alias of <A HREF="function.msql-result.html" ><B CLASS="function" >msql_result()</B ></A ></DT ><DT ><A HREF="function.msql.html" >msql</A > -- Alias of <A HREF="function.msql-db-query.html" ><B CLASS="function" >msql_db_query()</B ></A ></DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.msession-unlock.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.msql-affected-rows.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >msession_unlock</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >msql_affected_rows</TD ></TR ></TABLE ></DIV ></BODY ></HTML >