WordPress:从小部件代码访问数据库 [英] WordPress: Access Database From Widget Code

查看:80
本文介绍了WordPress:从小部件代码访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从小部件代码访问WordPress数据库并运行SQL? (我需要从小部件代码访问我的一个插件的设置)

How can I access to my WordPress database and run SQL from the widget code? (I need to access to the settings of one of my plugins from the widget code)

推荐答案

您可以检查 http://完整文档请参见codex.wordpress.org/Class_Reference/wpdb .在履历表中,您可以从小部件代码的任何部分执行以下操作:

You can check this http://codex.wordpress.org/Class_Reference/wpdb for full documentation. In resume you can do something like the follow from any part of your widget code:

global $wpdb;
$rows = $wpdb->get_results( "SELECT id, name FROM table" );

这篇关于WordPress:从小部件代码访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆