php-doc-en/reference/mysql/functions/mysql-db-query.xml
Kalle Sommer Nielsen 20a326f84d * Added caution note that ticks are deprecated as of 5.3
* Added note in changelog on the following functions that they will throw an E_DEPRECATED notice as of 5.3:
  * mktime() -- is_dst parameter is deprecated
  * register_tick_function()
  * mysql_db_query()
  * mysql_escape_string()
  * setlocale() -- Behavior of passing strings insted of one of the LC_* constants is deprecated


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@265410 c90b9560-bf6c-de11-be94-00142212c4b1
2008-08-24 07:26:26 +00:00

176 lines
4.3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<refentry xml:id="function.mysql-db-query" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysql_db_query</refname>
<refpurpose>Send a MySQL query</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>mysql_db_query</methodname>
<methodparam><type>string</type><parameter>database</parameter></methodparam>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam>
</methodsynopsis>
<para>
<function>mysql_db_query</function> selects a database, and executes a
query on it.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>database</parameter></term>
<listitem>
<para>
The name of the database that will be selected.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
The MySQL query.
</para>
</listitem>
</varlistentry>
&mysql.linkid.description;
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a positive MySQL result resource to the query result,
or &false; on error. The function also returns &true;/&false; for
<literal>INSERT</literal>/<literal>UPDATE</literal>/<literal>DELETE</literal>
queries to indicate success/failure.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
This function now throws an E_DEPRECATED notice.
</entry>
</row>
<row>
<entry>4.0.6</entry>
<entry>
This function is deprecated, do not use this function. Use
<function>mysql_select_db</function> and
<function>mysql_query</function> instead.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mysql_db_query</function> alternative example</title>
<programlisting role="php">
<![CDATA[
<?php
if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db('mysql_dbname', $link)) {
echo 'Could not select database';
exit;
}
$sql = 'SELECT foo FROM bar WHERE id = 42';
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['foo'];
}
mysql_free_result($result);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Be aware that this function does <emphasis role="strong">NOT</emphasis>
switch back to the database you were connected before. In other words,
you can't use this function to <emphasis>temporarily</emphasis> run a
sql query on another database, you would have to manually switch back.
Users are strongly encouraged to use the
<literal>database.table</literal> syntax in their sql queries or
<function>mysql_select_db</function> instead of this function.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysql_query</function></member>
<member><function>mysql_select_db</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:"../../../../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
-->