admin管理员组文章数量:1130349
So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()?
So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()?
- Why not use that array and get the string from it? – kero Commented Nov 13, 2018 at 17:32
- I converted it to JSON but still don't know how to access the string in the loop. I have an array of json objects here. Any hints? – Limpuls Commented Nov 13, 2018 at 17:55
1 Answer
Reset to default 1$wpdb->get_results() only returns arrays( associative or numeric) or an object. It does not return a string value.
If you want a string value, you need to use $wpdb->get_var() instead
So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()?
So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()?
- Why not use that array and get the string from it? – kero Commented Nov 13, 2018 at 17:32
- I converted it to JSON but still don't know how to access the string in the loop. I have an array of json objects here. Any hints? – Limpuls Commented Nov 13, 2018 at 17:55
1 Answer
Reset to default 1$wpdb->get_results() only returns arrays( associative or numeric) or an object. It does not return a string value.
If you want a string value, you need to use $wpdb->get_var() instead
本文标签: phpAny possible way to make wpdbgtgetresults() return anything else than array
版权声明:本文标题:php - Any possible way to make $wpdb->get_results() return anything else than array? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749182680a2328872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论