php - 如何从 Wordpress 博客的 MS SQL 检索外部数据?

标签 php sql-server wordpress

在 Wordpress 中,我如何从外部 Microsoft SQL 数据库中提取数据以显示为只读表格?

需要明确的是,这不是关于如何将 Wordpress 转换为 MS SQL 的问题,而是关于如何从主 Wordpress 数据库之外的源中为特定小部件提取数据的问题。我需要从中提取的数据恰好位于 MS SQL 数据库中。

举个例子,假设我需要提取商店位置和营业时间:

/* Retrieve store locations from the external MS SQL database*/

SELECT id, name, address, city, state, zip, phone, openingTime, closingTime
FROM locations
ORDER BY name

并将该数据显示到 Wordpress 页面上的表格中:

<table>
<tr>
    <th>Store Name</th>
    <th>Address</th>
    <th>Store Hours</th>
</tr>

<!-- Display rows of store locations here -->

</table>

最佳答案

Wordpress 在 PHP 上运行,因此您需要为 SQL Server 使用 PHP 提供程序。参见 Accessing SQL Server Databases with PHP .

如果您在 Linux 上托管 Wordpress,则需要 FreeTDS,请参阅 PHP mssql Requirements .

关于php - 如何从 Wordpress 博客的 MS SQL 检索外部数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2328224/

相关文章:

php - 如何将保存在服务器文件夹中的图像与 mySQL 数据库中的数据一起显示?

php - 无法编辑保存在数据库中的数据

mysql - SQL:如何在具有特定ID的特定列中插入数据

php - Wordpress is_page() 总是返回 false

wordpress - 如何将一个asp网站转换成wordpress?

php - WordPress 查询。正确引用页面摘录?

php - 如何配置 Laravel 应用程序以使用 heroku PostgreSQL hobby dev?

php - 检查登录脚本是否允许访客进入?

sql-server - UAT 数据应该是 Production 的镜像吗?如果是这样,怎么办?

sql - T-SQL 将来自不同行中最大长度列的行分组(?)