admin管理员组文章数量:1129202
I have a custom table in db with a column recommendation
of type int(11)
.
Then as one of my custom route handlers I have
global $wpdb;
$query = "SELECT recommendation FROM `restaurants`;
// todo convert "88" -> 88
$list1 = $wpdb->get_results($query);
return array('open' => $list1);
The data the front end receives is "88"
whereas this should be an int.
In some of my code I have a function that maps each $obj
in the list with
$obj->recommendation = (int) $obj->recommendation;
But it feels weird that I need to post process in php rather than get the data correctly from the db itself.
What is the 'best' way to achieve my goal?
本文标签: queryCustom API how to return int field
版权声明:本文标题:query - Custom API how to return int field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736738224a1950367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论