douwen7603 2015-11-12 11:16
浏览 92

在wordpress插件中将“mysql_fetch_array”更新为“$ wpdb-> get_results”

I'm updating some old wordpress plugin files and understand I need to update "mysql_fetch_array" to "$wpdb->get_results" to get the plugin to talk with the database.

Here is the code where "mysql_fetch_array" is used:

//select ads id's  stored into db table
$sql  = "SELECT id FROM $table_name_ad_google";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
{

How do I rewrite this to use $wpdb->get_results?

  • 写回答

1条回答 默认 最新

  • douchenbiao0916 2017-09-27 08:41
    关注
    $sql = "SELECT * FROM tbl_employee WHERE 1=1";
    $query = $wpdb->get_results($sql,ARRAY_A);
    foreach($query as $row){
    /*$row["your column name"];*/
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料