Files
doc-fr/reference/sqlite/functions/sqlite-array-query.xml
Yannick Torres fd8fc1cbdd sync with EN
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@177865 c90b9560-bf6c-de11-be94-00142212c4b1
2005-01-21 22:40:10 +00:00

122 lines
4.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- EN-Revision: 1.11 Maintainer: yannick Status: ready -->
<refentry id="function.sqlite-array-query">
<refnamediv>
<refname>sqlite_array_query</refname>
<refname>SQLiteDatabase->arrayQuery</refname>
<refpurpose>
Exécute une requête SQL avec SQLite et retourne un tableau
</refpurpose>
</refnamediv>
<refsect1>
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>sqlite_array_query</methodname>
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>array</type><methodname>sqlite_array_query</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam>
</methodsynopsis>
&title.oop;
<classsynopsis>
<ooclass><classname>SQLiteDatabase</classname></ooclass>
<methodsynopsis>
<type>array</type><methodname>arrayQuery</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>decode_binary</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
<function>sqlite_array_query</function> est similaire à
<function>sqlite_query</function> suivi de
<function>sqlite_fetch_array</function> pour chaque ligne de résultat,
et en les plaçant dans un tableau. Appeler <function>sqlite_array_query</function>
est plus rapide que de programmer cette séquence dans un script &php;.
</para>
&sqlite.result-type;
&sqlite.case-fold;
&sqlite.decode-bin;
<para>
<example>
<title><function>sqlite_array_query</function> traditionnel</title>
<programlisting role="php">
<![CDATA[
<?php
$q = sqlite_query($dbhandle, "SELECT name, email FROM users LIMIT 25");
$rows = array();
while ($r = sqlite_fetch_array($q)) {
$rows[] = $r;
}
?>]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Exemple avec <function>sqlite_array_query</function></title>
<programlisting role="php">
<![CDATA[
<?php
$dbhandle = sqlite_open('sqlitedb');
$result = sqlite_array_query($dbhandle, 'SELECT name, email FROM users LIMIT 25', SQLITE_ASSOC);
foreach ($result as $entry) {
echo 'Nom : ' . $entry['name'] . ' E-mail : ' . $entry['email'];
}
/* Exemple OO */
$dbhandle = new SQLiteDatabase('sqlitedb');
$result = $dbhandle->arrayQuery('SELECT name, email FROM users LIMIT 25', SQLITE_ASSOC);
foreach ($result as $entry) {
echo 'Nom : ' . $entry['name'] . ' E-mail : ' . $entry['email'];
}
?>
]]>
</programlisting>
</example>
</para>
<tip>
<para>
<function>sqlite_array_query</function> est bien adapté pour des
requêtes qui retournent jusqu'à 45 lignes. Si vous avez plus
de données, il est recommandé d'utiliser
<function>sqlite_unbuffered_query</function> pour optimiser les performances.
</para>
</tip>
&sqlite.param-compat;
<para>
Voir aussi
<function>sqlite_query</function>,
<function>sqlite_fetch_array</function> et
<function>sqlite_fetch_string</function>.
</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
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
-->