Store_result和get_result用于语句 [英] Store_result and get_result for statement

查看:137
本文介绍了Store_result和get_result用于语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在mysqli库中的PHP中使用语句时,在获取和bind_results之前,我先调用store_result. 在看完mysqli_result类后,使用了诸如fetchArray/object等方法. 因此,如果要使用它,我从mysqli_stmt对象调用方法get_results ...,但是如果在方法store_result之前调用它,则会给我一个非对象"错误(get_result返回false). 电子邮件:

When I use statements in PHP with mysqli library, before I fetch and bind_results I call the store_result. After I've seen the mysqli_result class with methods like fetchArray/object etc. So if I want use it, I call from mysqli_stmt object the method get_results... but if I call before the method store_result it give me an error of "non object" (get_result return false). Es:

$s = $stmt->get_result(); //this work

但如果我这样做

$stmt->store_result();
$s = $stmt->get_result(); //this not work, return false

因此,我试图了解何时需要使用store_result或get_result(以及正确的方法是什么),但是在Mysql和php doc中,我没有发现有用的东西.

So I'm trying to understand when I need to user store_result or get_result (and what is the right way) but in Mysql and php doc I didn't find nothing of useful.

PS:您能解释一下为什么我应该使用第一个或第二个吗?

PS: Can you explain why I should use the first or the second?

推荐答案

尽可能使用get_result,在其他地方使用store_result.

Use get_result whenever possible and store_result elsewhere.

这篇关于Store_result和get_result用于语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆