1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 07:02:15 +01:00
Files
archived-doc-zh/faq/databases.xml
2024-01-24 23:48:08 +08:00

170 lines
6.0 KiB
XML
Executable File
Raw Permalink 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"?>
<!-- $Revision$ -->
<!-- EN-Revision: b8e1b1357def73f310c9f7405035b3acc0cb1eaf Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<chapter xml:id="faq.databases" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>数据库问题</title>
<titleabbrev>数据库问题</titleabbrev>
<para>
本节包括 PHP 和数据库之间关系的常见问题。事实上PHP 可以访问如今现有的任何数据库。
</para>
<qandaset>
<qandaentry xml:id="faq.databases.mssql">
<question>
<para>
听说 PHP 有可能访问 Microsoft SQL Server怎样访问
</para>
</question>
<answer>
<para>
在 Unix 机器中,你可以使用 <link linkend="ref.pdo-odbc">PDO_ODBC</link>
或者 <link linkend="book.uodbc">Unified ODBC API</link> 来访问 Microsoft SQL Server 数据库。
</para>
<para>
在 Windows 机器中,你可以使用 <link linkend="ref.pdo-sqlsrv">PDO_SQLSRV</link>
<link linkend="book.sqlsrv">SQLSRV</link> 来访问 Microsoft SQL Server 数据库。
</para>
<para>
同时,也可以参考下一个问题。
</para>
</answer>
</qandaentry>
<qandaentry xml:id="faq.databases.access">
<question>
<para>能访问 Microsoft Access 数据库吗?</para>
</question>
<answer>
<para>
如果在 Unix 下运行 PHP 而想访问 Windows 中的 MS Access那需要 Unix ODBC
驱动程序。<link xlink:href="&url.openlink;">OpenLink Software</link>
有一个基于 Unix 的 ODBC 驱动程序可以做这件事。
</para>
<para>
另外一个替代方案是用带 Windows ODBC
驱动的 SQL Server 并用它来储存数据,
可以通过 Microsoft Access用 ODBC和 PHP用内置驱动来访问
或者用一个 Access 和 PHP 都识别的中间文件格式,
例如 flat 文件或者 dBase 数据库。
关于这一点 OpenLink Software 的 Tim Hayes 写道:
<blockquote>
<para>
当可以通过 ODBC 直接从 PHP 访问数据库时——例如用 OpenLink 的驱动程序,
使用其它数据库做中间媒介不是一个好主意。
如果确实需要一个中间文件格式,
OpenLink 已经发布了对应于 Windows NTLinux 和其它 Unix 平台的 Virtuoso一个虚拟数据库引擎
请访问我们的 <link xlink:href="&url.openlink;">网站</link>来免费下载。
</para>
</blockquote>
</para>
<para>
还有一个已被证实有效的选择是在 Windows 下用 MySQL
和它的 MyODBC 驱动来同步数据库。
Steve Lawrence 写道:
</para>
<para>
<itemizedlist>
<listitem>
<simpara>
根据 MySQL 的说明在你的平台上安装 MySQL。可以从
<link xlink:href="&url.mysql;">&url.mysql;</link>得到最新版。
除了设定数据库和配置用户帐号以外不需要特殊的配置,
应该在 host 字段中放一个 % 或者要用来访问 MySQL 的 Windows 机器名。
记下自己的服务器名,
用户名和密码。
</simpara>
</listitem>
<listitem>
<simpara>
从 MySQL 网站下载 MyODBC for Windows 驱动程序。
在你的 Windows 机器中安装它。
可以用此程序中包括的工具来测试其操作。
</simpara>
</listitem>
<listitem>
<simpara>
用控制面板中的 ODBC 管理器新建一个用户或系统 dsn
设定 dsn 名称,
输入你在第一步中配置的 MySQL 数据库的主机名,用户名,密码,端口等。
</simpara>
</listitem>
<listitem>
<simpara>
完整安装 Access
这样可以确保得到适当的插件...
至少需要安装 ODBC 支持和连接表管理器。
</simpara>
</listitem>
<listitem>
<simpara>
新建一个 Access 数据库。
在 Table 窗口点击右键并选择 Link Tables
或者在 File 菜单下选择 Get External Data -&gt; Link Tables。
当文件浏览窗口打开后选择文件类型为ODBC。
接着选择 System dsn 以及在第三步建立的 dsn 的名字。
再选择要连接的表,点击 OK。
现在你可以在你的 MySQL
服务器中打开表并新建/删除/编辑数据了!
也可以构造查询,导入/导出表到 MySQL构造表单和报告等。
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
提示与技巧:
<itemizedlist>
<listitem>
<simpara>
可以在 Access 中构造表并导出到 MySQL 中,
再把它们连接回来。
这样可以使表的建立更快。
</simpara>
</listitem>
<listitem>
<simpara>
在 Access 中建立表时,
必需定义一个基本键名来取得表的写权限。
确认在把表连接到 Access 之前在 MySQL
中建立了基本键名。
</simpara>
</listitem>
<listitem>
<simpara>
如果在 MySQL 中修改了表,
必须重新连接到 Access。
打开 Tools&gt;Add-ins&gt;Linked table manager
找到你的 ODBC DSN然后在这里选择要重新连接的表。
也可以在这里移动 dsn 源,
在点击 OK 之前选中 “always prompt for new location”。
</simpara>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
</qandaset>
</chapter>
<!-- 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
-->