php-doc-en/reference/maxdb/functions/maxdb-stmt-bind-param.xml
Jakub Vrana 4cffafa967 Fix protos
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@177407 c90b9560-bf6c-de11-be94-00142212c4b1
2005-01-17 10:51:20 +00:00

147 lines
4.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<refentry id="function.maxdb-stmt-bind-param">
<refnamediv>
<refname>maxdb_stmt_bind_param</refname>
<refpurpose>Binds variables to a prepared statement as parameters</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>Procedural style:</para>
<methodsynopsis>
<type>bool</type><methodname>maxdb_stmt_bind_param</methodname>
<methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
<methodparam><type>string</type><parameter>types</parameter></methodparam>
<methodparam><type>mixed</type><parameter role="reference">var1</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter role="reference">...</parameter></methodparam>
</methodsynopsis>
<para>
<function>maxdb_stmt_bind_param</function> is used to bind variables for the
parameter markers in the SQL statement that was passed to
<function>maxdb_prepare</function>.
The string <parameter>types</parameter> contains one or more characters which specify
the types for the corresponding bind variables
<table>
<title>Type specification chars</title>
<tgroup cols='2'>
<thead>
<row>
<entry>Character</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>i</entry>
<entry>corresponding variable has type integer</entry>
</row>
<row>
<entry>d</entry>
<entry>corresponding variable has type double</entry>
</row>
<row>
<entry>s</entry>
<entry>corresponding variable has type string</entry>
</row>
<row>
<entry>b</entry>
<entry>corresponding variable is a blob and will be send in packages</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1>
<title>Return values</title>
<para>
&return.success;
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>maxdb_stmt_bind_result</function>,
<function>maxdb_stmt_execute</function>,
<function>maxdb_stmt_fetch</function>,
<function>maxdb_prepare</function>,
<function>maxdb_stmt_send_long_data</function>,
<function>maxdb_stmt_errno</function>,
<function>maxdb_stmt_error</function>
</para>
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = maxdb_connect("localhost", "MONA", "RED");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
maxdb_query ($link, "CREATE TABLE temp.mycity LIKE hotel.city");
maxdb_query ($link, "INSERT INTO temp.mycity SELECT * FROM hotel.city");
$stmt = maxdb_prepare($link, "INSERT INTO temp.mycity VALUES (?, ?, ?)");
maxdb_stmt_bind_param($stmt, 'sss', $zip, $name, $state);
$zip = '11111';
$name = 'Georgetown';
$state = 'NY';
/* execute prepared statement */
maxdb_stmt_execute($stmt);
printf("%d Row inserted.\n", maxdb_stmt_affected_rows($stmt));
/* close statement and connection */
maxdb_stmt_close($stmt);
/* Clean up table CountryLanguage */
maxdb_query($link, "DELETE FROM temp.mycity WHERE name='Georgetown'");
printf("%d Row deleted.\n", maxdb_affected_rows($link));
/* close connection */
maxdb_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
1 Row inserted.
1 Row deleted.
]]>
</screen>
</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:"../../../../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
-->