1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 08:42:13 +01:00
Files
archived-doc-ru/reference/dbase/functions/dbase-numfields.xml
Sergey Panteleev daef8df962 Обнуление тега Reviewed (#364)
[skip-lint]
[skip-spellcheck]
2021-11-16 13:03:53 +03:00

142 lines
4.1 KiB
XML
Raw 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: 4754397753fd79f1c846868b66a2448babab1c54 Maintainer: aur Status: ready -->
<!-- Reviewed: no -->
<!-- Необходимо проверить работоспособность кода в примере -->
<refentry xml:id="function.dbase-numfields" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>dbase_numfields</refname>
<refpurpose>Получает количество полей базы данных</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>dbase_numfields</methodname>
<methodparam><type>resource</type><parameter>database</parameter></methodparam>
</methodsynopsis>
<para>
Получает количество полей (колонок) в указанной базе данных.
</para>
<note>
<para>
Поле номеруются от 0 до <literal>dbase_numfields($db)-1</literal>,
тогда как записи базы данных от 1 до <literal>dbase_numrecords($db)</literal>.
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>database</parameter></term>
<listitem>
<para>
Ресурс базы данных, возвращаемый функцией <function>dbase_open</function>
или <function>dbase_create</function>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Количество полей в базе данных или &false; в случае возникновения ошибки.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>dbase 7.0.0</entry>
<entry>
Параметр <parameter>database</parameter> теперь имеет тип
<type>resource</type>, а не <type>int</type>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>dbase_numfields</function></title>
<programlisting role="php">
<![CDATA[
<?php
//открытие БД для чтения
$db = dbase_open('.\tmp\test.dbf', 0);
//если соединение успешно, то выполняем действия
if ($db) {
//получение количества записей БД
$record_numbers = dbase_numrecords($db);
//получение количества полей БД
$nf = dbase_numfields($db);
//вывод всех записей БД
//построчный обход
for ($j = 1; $j <= $record_numbers; $j++) {
//вывод номера строки
echo $j."=>" ;
//получение строки по номеру (индексу)
$rec = dbase_get_record($db, $j);
//обход по столбцам
for ($i = 0; $i < $nf; $i++) {
//вывод данных поля
echo $rec[$i], "\t";
}
echo "<br>";
}
dbase_close($db);
} else echo "Не удалось подключиться к БД";
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>dbase_numrecords</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
-->