doujiyan0971 2011-01-27 20:31
浏览 31
已采纳

在wordpress中进行查询?

I am editing an index.php file in the themes folder and I just need to run a query but I cant seem to run a query...here is what i tried

i tried to include the config files

<?php require( dirname(__FILE__) . '/wp-load.php'); ?> 
<?php print DB_NAME;exit; ?>

that printed nothing

then i tried to do the mysql_query command

mysql_connect($server, $username, $password)
$users = mysql_query("select * ....");
print_r($users); exit;

nothing in either one....i know there has got to be an easier way to do a query in wordpress...any ideas

  • 写回答

1条回答 默认 最新

  • dongqian9567 2011-01-27 20:34
    关注

    Don't use mysql directly (as a mysql connection already exists). Instead use the wpdb 'abstraction' - see the wordpress documentation here: http://codex.wordpress.org/Function_Reference/wpdb_Class

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM