1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-27 01:02:19 +01:00
Files
archived-doc-ru/reference/pgsql/functions/pg-delete.xml
2021-02-07 19:02:29 +03:00

159 lines
6.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 7d763b79e5d29ab6702d72d85187267f828562c6 Maintainer: das Status: ready -->
<!-- Reviewed: yes Maintainer: lex -->
<!-- $Revision$ -->
<refentry xml:id='function.pg-delete' xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>pg_delete</refname>
<refpurpose>
Удаляет записи
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>pg_delete</methodname>
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
<methodparam><type>array</type><parameter>assoc_array</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>PGSQL_DML_EXEC</initializer></methodparam>
</methodsynopsis>
<para>
<function>pg_delete</function> удаляет из таблицы записи, соответствующие ключам и значениям
массива <parameter>assoc_array</parameter>. Если задан аргумент <parameter>options</parameter>,
то массив <parameter>assoc_array</parameter> будет предварительно обработан
функцией <function>pg_convert</function>, вызванной с указанными
параметрами.
</para>
<para>Если <literal>options</literal> указан,
<function>pg_convert</function> применяется к
<literal>assoc_array</literal> с указанными флагами.
</para>
<para>
По умолчанию <function>pg_delete</function> передаёт необработанные значения.
Значения должны быть экранированы или опция PGSQL_DML_ESCAPE должна быть
указана. PGSQL_DML_ESCAPE заключает в кавычки и экранирует
параметры/идентификаторы. Поэтому имена таблиц/столбцов становятся
чувствительными к регистру.
</para>
<para>
Обратите внимание, что ни экранирование, ни подготовленный запрос не защитят запрос LIKE,
JSON, массив, регулярные выражения и т.д.. Эти параметры должны обрабатываться
в соответствии с их контекстами, т.е. следует экранировать/проверять значения.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>connection</parameter></term>
<listitem>
<para>
Ресурс соединения с базой данных PostgreSQL.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>table_name</parameter></term>
<listitem>
<para>
Имя таблицы, из которой удаляются записи.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>assoc_array</parameter></term>
<listitem>
<para>
Ассоциативный массив, ключи которого соответствуют именам полей таблицы <parameter>table_name</parameter>,
а значения соответствуют удаляемым значениям в этих колонках.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
Комбинация констант <constant>PGSQL_CONV_FORCE_NULL</constant>,
<constant>PGSQL_DML_NO_CONV</constant>,
<constant>PGSQL_DML_ESCAPE</constant>,
<constant>PGSQL_DML_EXEC</constant>,
<constant>PGSQL_DML_ASYNC</constant> или
<constant>PGSQL_DML_STRING</constant>.
Если константа <constant>PGSQL_DML_STRING</constant> присутствует
в аргументе <parameter>options</parameter>, то функция вернёт
строку, содержащую запрос. Если установлены <constant>PGSQL_DML_NO_CONV</constant>
или <constant>PGSQL_DML_ESCAPE</constant>, то функция <function>pg_convert</function> внутренне не вызывается.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success; Возвращает строку, если в аргументе <parameter>options</parameter>
передана константа <constant>PGSQL_DML_STRING</constant>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>pg_delete</function></title>
<programlisting role="php">
<![CDATA[
<?php
$db = pg_connect('dbname=foo');
// Это безопасно в некоторой степени, поскольку все значения экранируются.
// Однако PostgreSQL поддерживает JSON/массив. Для этих значений это не безопасно
// ни с через экранирование, ни с помощью подготовленного запроса.
$res = pg_delete($db, 'post_log', $_POST, PG_DML_ESCAPE);
if ($res) {
echo "Данные из POST удалены: $res\n";
} else {
echo "Пользователь отправил неверные входные данные\n";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>pg_convert</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
-->