/
store-result.xml
138 lines (130 loc) · 4.75 KB
/
store-result.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 90953eddaa06c6c83faf0dea76c241dfafeaa2a1 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="mysqli.store-result" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysqli::store_result</refname>
<refname>mysqli_store_result</refname>
<refpurpose>传输上次查询的结果集</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>&style.oop;</para>
<methodsynopsis role="mysqli">
<modifier>public</modifier> <type class="union"><type>mysqli_result</type><type>false</type></type><methodname>mysqli::store_result</methodname>
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>&style.procedural;</para>
<methodsynopsis>
<type class="union"><type>mysqli_result</type><type>false</type></type><methodname>mysqli_store_result</methodname>
<methodparam><type>mysqli</type><parameter>mysql</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
传输由 <parameter>mysql</parameter> 参数表示的连接上的上一次查询的结果集,可在
<function>mysqli_data_seek</function> 函数中使用。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&mysqli.link.description;
<varlistentry>
<term><parameter>mode</parameter></term>
<listitem>
<para>
想要设置的选项。自 PHP 8.1 起,此参数无效。可以是下列中的某一值:
<table xml:id="mysqli.store-result.parameters">
<title>有效选项</title>
<tgroup cols="2">
<thead>
<row>
<entry>名称</entry>
<entry>说明</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>MYSQLI_STORE_RESULT_COPY_DATA</constant></entry>
<entry>将结果从内部 mysqlnd 缓冲区复制到 PHP 变量中。默认 mysqlnd
采取引用策略来避免在内容中复制多份同样的结果集。例如,对于包含了很多小行的结果集,复制方法可以减少整体内存使用,因为保存结果的
PHP 变量可能会更早释放。(此选项适用于 mysqlnd 驱动)。</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
返回缓冲的结果对象,如果发生错误则返回 &false;。
</para>
<note>
<para>
如果查询没有返回结果集(例如,执行 INSERT 语句查询),<function>mysqli_store_result</function>
会返回 &false;。如果读取结果集失败,也会返回 &false;。如果通过检查 <function>mysqli_error</function>
是否返回非空字符串、<function>mysqli_error</function> 或 <function>mysqli_field_count</function>
是否返回了非零值来检查是否有错误。此函数在成功调用 <function>mysqli_query</function> 后返回 &false;
的一个可能原因是结果集太大(无法分配内存)。如果 <function>mysqli_field_count</function>
返回非零值,语句应该产生非空结果集。
</para>
</note>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
&mysqli.conditionalexception;
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
参阅 <function>mysqli_multi_query</function>。
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
执行查询之后,使用 <function>mysqli_free_result</function>
函数来释放结果集所占用的内存,是一个很有用的实战经验。尤其是当使用
<function>mysqli_store_result</function>
函数来转移数量较大的结果集的时候,释放结果集内存的操作尤为重要。
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysqli_real_query</function></member>
<member><function>mysqli_use_result</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->