简体   繁体   English

如何使用wordpress连接sql数据库

[英]How to connect sql database with wordpress

I wrote a sql database code and wanted to connect it with a wordpress to create a web page. 我写了一个sql数据库代码,并想用wordpress连接它来创建一个网页。 I searched for how to do it but i did not find the answer. 我搜索了怎么做,但我找不到答案。 How can i connect the sql code with wordoress? 如何用wordoress连接sql代码? If it can't be do you any recommendations for something else than wordpress accept sql database? 如果它不能为你做任何建议除了wordpress接受sql数据库?

I used oracle sql developer 我用过oracle sql developer

WordPress/ClassicPress system requirements : WordPress / ClassicPress系统要求

  • PHP version 7.3 or greater. PHP 7.3或更高版本。
  • MySQL version 5.6 or greater OR MariaDB version 10.1 or greater. MySQL 5.6或更高版本或MariaDB版本10.1或更高版本。
  • HTTPS support. HTTPS支持。

WP/CP uses it's own database structure and strongly discourages running direct SQL queries from the code. WP / CP使用它自己的数据库结构,强烈反对从代码中运行直接SQL查询。 There is a special global variable $wpdb (an instance of a wpdb class ) which should be used to perform any database request. 有一个特殊的全局变量$wpdb (一个wpdb类的实例),它应该用于执行任何数据库请求。

If you want to use WP, you should probably convert your SQL database to match WP native structure (if it's possible) and then use $wpdb to manage your tables/rows/fields. 如果你想使用WP,你应该转换你的SQL数据库以匹配WP本机结构(如果可能),然后使用$wpdb来管理你的表/行/字段。

Otherwise if you really need a custom database structure, you might want to build a custom solution with some common PHP frameworks like Laravel ( Database: Getting Started ) or Yii2 ( Working with Databases ). 否则,如果您确实需要自定义数据库结构,则可能需要使用一些常见的PHP框架(如Laravel数据库:入门 )或Yii2使用数据库 ))构建自定义解决方案。

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

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