mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
185 lines
5.8 KiB
XML
185 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: c68bcb2af14260247d8afe5e13d957e10e44c4af Maintainer: leonardolara Status: ready -->
|
|
<refentry xml:id="function.odbc-connect" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>odbc_connect</refname>
|
|
<refpurpose>Conecta a uma fonte de dados</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>Odbc\Connection</type><type>false</type></type><methodname>odbc_connect</methodname>
|
|
<methodparam><type>string</type><parameter>dsn</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>user</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><modifier role="attribute">#[\SensitiveParameter]</modifier><type class="union"><type>string</type><type>null</type></type><parameter>password</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>cursor_option</parameter><initializer><constant>SQL_CUR_USE_DRIVER</constant></initializer></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
O ID de conexão retornado por essas funções é necessário para outras
|
|
funções ODBC. Podem existir várias conexões abertas ao mesmo tempo, desde que
|
|
usem bancos de dados diferentes ou credenciais diferentes.
|
|
</simpara>
|
|
<simpara>
|
|
Com alguns drivers ODBC, a execução de um procedimento armazenado complexo pode
|
|
falhar com um erro semelhante a: "Não é possível abrir um cursor em um procedimento
|
|
armazenado que contenha algo diferente de uma única instrução
|
|
SELECT". Usar SQL_CUR_USE_ODBC pode evitar esse erro. Além disso, alguns
|
|
drivers não suportam o parâmetro row_number opcional em
|
|
<function>odbc_fetch_row</function>. SQL_CUR_USE_ODBC também pode ajudar
|
|
nesse caso.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>dsn</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O nome da fonte do banco de dados para a conexão. Como alternativa, uma
|
|
string de conexão sem DSN pode ser usada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>user</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O nome de usuário.
|
|
Este parâmetro é ignorado se <parameter>dsn</parameter> contiver <literal>uid</literal>.
|
|
Para conectar sem especificar o parâmetro <parameter>user</parameter>,
|
|
use &null;.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>password</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A senha.
|
|
Este parâmetro é ignorado se <parameter>dsn</parameter> contiver <literal>pwd</literal>.
|
|
Para conectar sem especificar o parâmetro <parameter>password</parameter>,
|
|
use &null;.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>cursor_option</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Este parâmetro define o tipo de cursor a ser usado
|
|
para esta conexão. Este parâmetro normalmente não é necessário, mas
|
|
pode ser útil para solucionar problemas com alguns drivers ODBC.
|
|
</para>
|
|
<simpara>
|
|
As seguintes constantes são definidas para o tipo de cursor:
|
|
</simpara>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
SQL_CUR_USE_IF_NEEDED
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SQL_CUR_USE_ODBC
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SQL_CUR_USE_DRIVER
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna uma conexão ODBC, &return.falseforfailure;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&odbc.changelog.connection-return;
|
|
&odbc.changelog.credential-params;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Conexões sem DSN</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Microsoft SQL Server usando o Driver ODBC SQL Native Client 10.0 - permite conexão ao SQL 7, 2000, 2005 e 2008
|
|
$connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);
|
|
|
|
// Microsoft Access
|
|
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);
|
|
|
|
// Microsoft Excel
|
|
$excelFile = realpath('C:/ExcelData.xls');
|
|
$excelDir = dirname($excelFile);
|
|
$connection = odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', '');
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member>Para conexões persistentes: <function>odbc_pconnect</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|