mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 15:12:23 +01:00
134 lines
3.6 KiB
XML
134 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 5f1a92089fa4efe81e9777f87f9ed93f4853898b Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.61 -->
|
|
<refentry xml:id='function.pg-escape-string' xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_escape_string</refname>
|
|
<refpurpose>
|
|
Escapa uma string para consulta
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>pg_escape_string</methodname>
|
|
<methodparam choice="opt"><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>data</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_escape_string</function> escapa uma string para consultar
|
|
o banco de dados. Ele retorna uma string de escape no formato PostgreSQL
|
|
sem aspas. <function>pg_escape_literal</function> é
|
|
a forma preferida de escapar dos parâmetros SQL para PostgreSQL.
|
|
<function>addslashes</function> não deve ser usado com PostgreSQL.
|
|
Se o tipo da coluna for
|
|
bytea, <function>pg_escape_bytea</function> deverá ser usado
|
|
no lugar. <function>pg_escape_identifier</function> deve ser usado para
|
|
escape de identificadores (por exemplo, nomes de tabelas, nomes de campos)
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
&pgsql.parameter.connection-with-unspecified-default;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Uma <type>string</type> contendo texto a ser escapado.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Uma <type>string</type> contendo os dados escapados.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&pgsql.changelog.connection-object;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>pg_escape_string</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Conecta ao banco de dados
|
|
$dbconn = pg_connect('dbname=foo');
|
|
|
|
// Lê em um arquivo de texto (contendo apóstrofos e barras invertidas)
|
|
$data = file_get_contents('letter.txt');
|
|
|
|
// Escape dos dados de texto
|
|
$escaped = pg_escape_string($data);
|
|
|
|
// Insira-o no banco de dados
|
|
pg_query("INSERT INTO correspondence (name, data) VALUES ('My letter', '{$escaped}')");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_escape_bytea</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
|
|
-->
|