脚本宝典收集整理的这篇文章主要介绍了PHP – bind_result到数组,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$read_ITems = $db->stmt_init(); $read_items->PRepare("SELECT item_id,item_name From items"); $read_items->execute(); $read_items->bind_result($VAR1,$var2); while ($read_items->fetch()) { $item_id[] = $var1; $item_name[] = $var2; }
是否有更清晰/更好/更优雅的方式将结果放入$item_id和$item_name数组?
从上面可以看出,我使用$var1和$var2就像“中间人” – 并且不断感觉必须有更好的方法.
谢谢.
<?PHP // blah blah... call_user_func_array(array($MysqLi_stmt_object,"bind_result"),$byref_array_for_fields); // returns a copy of a value $copy = create_function('$a','return $a;'); $results = array(); while ($MysqLi_stmt_object->fetch()) { // array_map will preserve keys when done here and this way $results[] = array_map($copy,$byref_array_for_fields); }
以上是脚本宝典为你收集整理的PHP – bind_result到数组全部内容,希望文章能够帮你解决PHP – bind_result到数组所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。