mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 07:22:16 +01:00
177 lines
5.1 KiB
XML
177 lines
5.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 39bb8a868935a56cfce438b0169e13c02c93211c Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.pg-convert" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_convert</refname>
|
|
<refpurpose>
|
|
Convierte valores de un array asociativo a una forma adecuada para consultas SQL
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>pg_convert</methodname>
|
|
<methodparam><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>values</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_convert</function> verifica y convierte el array
|
|
asociativo <parameter>values</parameter> en una consulta SQL válida.
|
|
Para que <function>pg_convert</function> funcione, debe existir la tabla
|
|
<parameter>table_name</parameter>, y debe contener al menos tantas columnas
|
|
como elementos tenga el array <parameter>values</parameter>. Los nombres de
|
|
los campos de <parameter>table_name</parameter> deben corresponder a los índices
|
|
del array en <parameter>values</parameter>.
|
|
Devuelve un array con los valores convertidos en caso de éxito, y de lo contrario,
|
|
&false;.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Los valores booleanos son admitidos y convertidos a booleanos PostgreSQL.
|
|
Las representaciones de valores booleanos en forma de strings también son soportadas. &null; es convertido a NULL PostgreSQL.
|
|
</para>
|
|
</note>
|
|
</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>
|
|
Nombre de la tabla para la cual se convertirán los tipos.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>values</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Datos a ser convertidos.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un número de <constant>PGSQL_CONV_IGNORE_DEFAULT</constant>,
|
|
<constant>PGSQL_CONV_FORCE_NULL</constant> o
|
|
<constant>PGSQL_CONV_IGNORE_NOT_NULL</constant>, combinados.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Un &array; de valores convertidos, &return.falseforfailure;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Se lanza una <classname>ValueError</classname> o <classname>TypeError</classname>
|
|
cuando el valor o el tipo del campo no coincide correctamente con un tipo PostgreSQL.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.3.0</entry>
|
|
<entry>
|
|
Ahora lanza un error <classname>ValueError</classname> o <classname>TypeError</classname>
|
|
cuando el valor o el tipo del campo no coincide correctamente con un tipo PostgreSQL;
|
|
previamente, se emitía un <constant>E_WARNING</constant>.
|
|
</entry>
|
|
</row>
|
|
&pgsql.changelog.connection-object;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo con <function>pg_convert</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$dbconn = pg_connect('dbname=foo');
|
|
|
|
$tmp = array(
|
|
'auteur' => 'Joe Thackery',
|
|
'annee' => 2005,
|
|
'titre' => 'Ma Vie, par Joe Thackery'
|
|
);
|
|
|
|
$vals = pg_convert($dbconn, 'auteurs', $tmp);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_meta_data</function></member>
|
|
<member><function>pg_insert</function></member>
|
|
<member><function>pg_select</function></member>
|
|
<member><function>pg_update</function></member>
|
|
<member><function>pg_delete</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
|
|
-->
|