1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 15:52:13 +01:00
Files
archived-doc-ru/reference/pgsql/functions/pg-delete.xml
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

171 lines
6.4 KiB
XML
Raw Permalink 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: c2eca73ef79ebe78cebb34053e41b565af504c4f Maintainer: das Status: ready -->
<!-- Reviewed: no -->
<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 class="union"><type>string</type><type>bool</type></type><methodname>pg_delete</methodname>
<methodparam><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
<methodparam><type>array</type><parameter>conditions</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>PGSQL_DML_EXEC</constant></initializer></methodparam>
</methodsynopsis>
<para>
<function>pg_delete</function> удаляет из таблицы записи, соответствующие ключам и значениям
массива <parameter>conditions</parameter>.
</para>
<para>
Если <parameter>flags</parameter> указан,
<function>pg_convert</function> применяется к
<literal>conditions</literal> с указанными флагами.
</para>
<para>
По умолчанию <function>pg_delete</function> передаёт необработанные значения.
Значения должны быть экранированы или опция <constant>PGSQL_DML_ESCAPE</constant> должна быть
указана. <constant>PGSQL_DML_ESCAPE</constant> заключает в кавычки и экранирует
параметры/идентификаторы. Поэтому имена таблиц/столбцов становятся
чувствительными к регистру.
</para>
<para>
Обратите внимание, что ни экранирование, ни подготовленный запрос не защитят запрос LIKE,
JSON, массив, регулярные выражения и т.д. Эти параметры должны обрабатываться
в соответствии с их контекстами, т.е. следует экранировать/проверять значения.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>connection</parameter></term>
<listitem>
&pgsql.parameter.connection;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>table_name</parameter></term>
<listitem>
<para>
Имя таблицы, из которой удаляются записи.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>conditions</parameter></term>
<listitem>
<para>
Ассоциативный массив, ключи которого соответствуют именам полей таблицы <parameter>table_name</parameter>,
а значения соответствуют удаляемым значениям в этих колонках.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</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>flags</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>flags</parameter>
передана константа <constant>PGSQL_DML_STRING</constant>.
</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>Пример использования <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
-->