简体   繁体   English

我可以在WordPress网站上使用普通的php与自己的自定义mysql数据库一起使用吗?

[英]Can I use ordinary php to work with my own custom mysql database in a wordpress site?

i have an old web db application written in classic asp with access way back in 2002. now i need to revive the project, and i've been studying php and mysql. 我有一个旧的以经典ASP编写的Web数据库应用程序,其访问方式可以追溯到2002年。现在我需要恢复该项目,并且我一直在研究php和mysql。 am pretty new to wordpress, but very eager to learn. 对wordpress来说是一个很新的概念,但是非常渴望学习。

is it possible for me to use wordpress as my cms, then in a custom post (which i stumbled upon online as i was researching this) connect to a mysql database (manually migrated from my access file) using standard php code to output whatever i need? 是否有可能我使用wordpress作为我的cms,然后在一个自定义帖子(我在研究此过程时在网上偶然发现)使用标准php代码连接到mysql数据库(手动从访问文件中迁移)以输出任何我需要?

is there a better approach to all this? 有没有更好的方法来解决这一切? sorry, my googling has actually left me with more questions than answers. 抱歉,我的谷歌搜索实际上给我带来的问题多于答案。

thanks in advance guys, appreciate the help. 在此先感谢大家,感谢您的帮助。

As I understand it, your require Wordpress to take care of your blog and do some processing on the data from some other PHP script. 据我了解,您需要Wordpress来处理您的博客,并对其他PHP脚本中的数据进行一些处理。 This is very much possible. 这很有可能。 When migrating to MySQL make sure you migrate your existing data to the format that Wordpress requires. 迁移到MySQL时,请确保将现有数据迁移到Wordpress所需的格式。 You can use mysql_query , mysql_connect and related functions to manage your processing. 您可以使用mysql_query ,mysql_connect和相关函数来管理您的处理。

The other option (one that a lot of people will recommend) is to write a WordPress plugin instead of a plain PHP script. 另一种选择(很多人会推荐的一种选择)是编写WordPress插件而不是普通的PHP脚本。 See http://codex.wordpress.org/Developer_Documentation to get started 请参阅http://codex.wordpress.org/Developer_Documentation入门

Yes you can, Wordpress only extends the existing functions of php with there own but never replaces them. 是的,您可以,Wordpress仅使用自己的现有功能扩展了php的现有功能,但从未取代它们。 You can either create a new page type or make a pluggin that shows the information you need. 您可以创建一个新的页面类型,也可以创建一个插件来显示所需的信息。

a new page would just open en close the connection with the external database as you would normally en probably easiest to use if your used to programming in php. 一个新页面将打开并关闭与外部数据库的连接,因为如果您以前使用php编程,通常通常最容易使用。

making a plugging would also allow you to simply open and close the database but requires you more research into the working of Wordpress self. 进行插入操作还可以使您简单地打开和关闭数据库,但需要对Wordpress self的工作进行更多研究。 The advantiges of using a puggin for this that you can define shorttags for Wordpress to use in your blog or site. 为此,您可以使用puggin的优点是可以定义要在您的博客或网站中使用的Wordpress的标记。 more info on this can be found in the Wordpress documentations http://codex.wordpress.org/Developer_Documentation . 有关更多信息,请参见Wordpress文档http://codex.wordpress.org/Developer_Documentation

the question of if there is a better way to do this? 是否有更好的方法可以解决这个问题? how about just use the database that you use for your information for the Wordpress tables. 仅使用您用于Wordpress表信息的数据库怎么样? Wordpress doesn't stop you from reusing the same database for the site for other things like storing data you want to use on your site. Wordpress不会阻止您将网站的数据库重复用于其他用途,例如存储要在网站上使用的数据。 It's easier to do because there is already an open connection to that database on every page. 这样做更容易,因为每个页面上已经有一个到该数据库的开放连接。 you only need to use the default PHP functions to retrieve the data. 您只需要使用默认的PHP函数来检索数据。 This is what I recome you do no matter how you extract the data afterworts. 我认为这是您做的事,无论您如何提取残渣数据。 If the custom database is already created than you can just tell Wordpress to install it self in that database. 如果已经创建了自定义数据库,则可以告诉Wordpress在该数据库中自行安装。 seeing that it uses WP_ as prefix it should not cause trouble. 看到它使用WP_作为前缀,应该不会造成麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM