[英]Wordpress database query not returning results
apologies that this is very basic stuff but would really appreciate some help. 抱歉,这是非常基本的内容,但确实会有所帮助。 I am trying to query a table in my Wordpress database by adding the following to my child theme's functions.php 我试图通过将以下内容添加到子主题的functions.php中来查询Wordpress数据库中的表
$myresults = $wpdb->get_results("SELECT id FROM wp_my_table WHERE user_id=1");
I am trying to view the results of the query by adding 我正在尝试通过添加查看查询的结果
<?php
var_dump($myresults);
?>
to one of the pages on my website, but it just displays 'NULL'. 到我网站上的页面之一,但只显示“ NULL”。 I have checked using phpMyAdmin and wp_my_table definitely exists, and contains entries where user_id=1. 我已经使用phpMyAdmin检查过,并且wp_my_table确实存在,并且其中包含user_id = 1的条目。 Any ideas? 有任何想法吗?
not get_results!!! 没有get_results! query 询问
$wpdb->get_results(...
to 至
$wpdb->query(...
抱歉,我错过了一些明显的事情-$ myresults变量的范围未扩展到我正在执行var_dump的页面上!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.