<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >mSQL</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.msession-unlock.html" ACCESSKEY="P" >Anterior</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" >Próxima</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</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN124659" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.intro" >Introdução</A ></H1 ><P > Estas funções permitem acessar servidores de banco de dados mSQL. Maiores informações sobre o mSQL podem ser encontradas em <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" >Instalação</A ></H1 ><P > Para ter estas funções disponíveis, você deve compilar o PHP com suporte ao msql usando a opção <CODE CLASS="option" >--with-msql[=DIR]</CODE >. DIR é o diretório base da instalação do msql, cujo padrão é <TT CLASS="filename" >/usr/local/msql3</TT >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota para os usuários de Note to Win32 Users: </B > Para ativar este módulo no ambiente Windows, você deve copiar <TT CLASS="filename" >msql.dll</TT > apartir da pasta DLL do pacote PHP/Win32 para a pasta SYSTEM32 no seu computador com windows. (Ex: <TT CLASS="filename" >C:\WINNT\SYSTEM32</TT > ou <TT CLASS="filename" >C:\WINDOWS\SYSTEM32</TT >) </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.configuration" >Configurações em execução</A ></H1 ><P > O comportamento dessas funções podem ser modificado pelas configurações do <TT CLASS="filename" >php.ini</TT >. </P ><P > <DIV CLASS="table" ><A NAME="AEN124680" ></A ><P ><B >Tabela 1. Opções de configuração do mSQL</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Nome</TH ><TH >Padrão</TH ><TH >Modificável</TH ></TR ></THEAD ><TBODY ><TR ><TD >msql.allow_persistent</TD ><TD >"On"</TD ><TD >PHP_INI_SYSTEM</TD ></TR ><TR ><TD >msql.max_persistent</TD ><TD >"-1"</TD ><TD >PHP_INI_SYSTEM</TD ></TR ><TR ><TD >msql.max_links</TD ><TD >"-1"</TD ><TD >PHP_INI_SYSTEM</TD ></TR ></TBODY ></TABLE ></DIV > Para maiores detalhes e definições das constantes PHP_INI_* veja <A HREF="function.ini-set.html" ><B CLASS="function" >ini_set()</B ></A >. </P ><P >Breve descrição das diretivas de configuração.</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 > Quando permitir conexões persistentes mSQL. </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 > O número máximo de conexões persistentes mSQL por processo. </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 > O número máximo de conexões mSQL por processo, incluindo as conexões persistentes. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.resources" >Tipos Resource</A ></H1 ><P > Existem dois tipos de recursos usados no módulo mSQL. O primeiro é o identificador de conexão para a conexão com o banco de dados, e o segundo é um recurso que guarda o resultado de uma consulta. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="msql.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </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" >Exemplos</A ></H1 ><P > Este exemplo simples mostra como conectar, realizar uma consulta, mostrar as linhas do resultado e disconectar do banco de dados mSQL. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN124751" ></A ><P ><B >Exemplo 1. Exemplo de uso do mSQL</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br /></font><font color="#FF8000">/* Conectando, selecionando o banco de dados */<br /><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 /><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 /> <br /><br /></font><font color="#0000BB">msql_select_db</font><font color="#007700">(</font><font color="#DD0000">'database'</font><font color="#007700">)<br /><br /> or die(</font><font color="#DD0000">'Could not select database'</font><font color="#007700">, </font><font color="#0000BB">$link</font><font color="#007700">);<br /><br /> <br /><br /></font><font color="#FF8000">/* Realizando a consulta SQL */<br /><br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'SELECT * FROM my_table'</font><font color="#007700">;<br /><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 /> <br /><br /></font><font color="#FF8000">/* Mostrando os resultados em HTML */<br /><br /></font><font color="#007700">echo </font><font color="#DD0000">"<table>\n"</font><font color="#007700">;<br /><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 /><br /> echo </font><font color="#DD0000">"\t<tr>\n"</font><font color="#007700">;<br /><br /> foreach (</font><font color="#0000BB">$row </font><font color="#007700">as </font><font color="#0000BB">$col_value</font><font color="#007700">) {<br /><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 /> }<br /><br /> echo </font><font color="#DD0000">"\t</tr>\n"</font><font color="#007700">;<br /><br />}<br /><br />echo </font><font color="#DD0000">"</table>\n"</font><font color="#007700">;<br /><br /> <br /><br /></font><font color="#FF8000">/* Liberando o conjunto de resultados */<br /><br /></font><font color="#0000BB">msql_free_result</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">);<br /><br /> <br /><br /></font><font color="#FF8000">/* Fecha a conexão */<br /><br /></font><font color="#0000BB">msql_close</font><font color="#007700">(</font><font color="#0000BB">$link</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.msql-affected-rows.html" >msql_affected_rows</A > -- Retorna o número de registros afetados pela última consulta</DT ><DT ><A HREF="function.msql-close.html" >msql_close</A > -- Fecha uma conexão mSQL</DT ><DT ><A HREF="function.msql-connect.html" >msql_connect</A > -- Abre uma conexão mSQL</DT ><DT ><A HREF="function.msql-create-db.html" >msql_create_db</A > -- Cria um banco de dados mSQL</DT ><DT ><A HREF="function.msql-createdb.html" >msql_createdb</A > -- Apelido para <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 o ponteiro interno dos registros</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 > -- Retorna o nome do banco de dados mSQL atual</DT ><DT ><A HREF="function.msql-drop-db.html" >msql_drop_db</A > -- Exclui um banco de dados mSQL</DT ><DT ><A HREF="function.msql-error.html" >msql_error</A > -- Retorna a mensagem de erro da última chamada a msql</DT ><DT ><A HREF="function.msql-fetch-array.html" >msql_fetch_array</A > -- Obtém um registro como uma matriz</DT ><DT ><A HREF="function.msql-fetch-field.html" >msql_fetch_field</A > -- Retorna informação sobre um campo</DT ><DT ><A HREF="function.msql-fetch-object.html" >msql_fetch_object</A > -- Obtem uma linha como um objeto</DT ><DT ><A HREF="function.msql-fetch-row.html" >msql_fetch_row</A > -- Retorna uma linha como uma matriz numerada</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 > -- Estabelece o índice do campo</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 > -- Apelido para <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 > -- Apelido para <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 > -- Apelido para <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 > -- Apelido para <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 > -- Apelido para <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 > -- Libera o resultado de uma consulta da memória</DT ><DT ><A HREF="function.msql-list-dbs.html" >msql_list_dbs</A > -- Lista os banco de dados mSQL no servidor</DT ><DT ><A HREF="function.msql-list-fields.html" >msql_list_fields</A > -- Lista os campos de uma tabela</DT ><DT ><A HREF="function.msql-list-tables.html" >msql_list_tables</A > -- Lista as tabelas em um banco de dados mSQL</DT ><DT ><A HREF="function.msql-num-fields.html" >msql_num_fields</A > -- Retorna o número de campos em um resultado</DT ><DT ><A HREF="function.msql-num-rows.html" >msql_num_rows</A > -- Retorna o número de registros em um resultado</DT ><DT ><A HREF="function.msql-numfields.html" >msql_numfields</A > -- Apelido para <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 > -- Abre uma conexão mSQL persistente</DT ><DT ><A HREF="function.msql-query.html" >msql_query</A > -- Envia uma consulta</DT ><DT ><A HREF="function.msql-regcase.html" >msql_regcase</A > -- Apelido para <A HREF="function.sql-regcase.html" ><B CLASS="function" >sql_regcase()</B ></A ></DT ><DT ><A HREF="function.msql-result.html" >msql_result</A > -- Retorna dados do resultado</DT ><DT ><A HREF="function.msql-select-db.html" >msql_select_db</A > -- Seleciona um banco de dados mSQL</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 > -- Apelido para <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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.msql-affected-rows.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >msql_affected_rows</TD ></TR ></TABLE ></DIV ></BODY ></HTML >