blob: 6fea7c6be223c9d3dd5c7319bfaadce332eb29e9 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001########################
2Generating Query Results
3########################
4
5There are several ways to generate query results:
6
James L Parry15162192014-12-05 23:40:47 -08007.. contents::
8 :local:
9 :depth: 2
10
James L Parry014bc892014-11-24 17:14:19 -080011*************
12Result Arrays
13*************
14
Andrey Andreevab0034b2014-12-11 18:31:51 +020015**result()**
Derek Jones8ede1a22011-10-05 13:34:52 -050016
James L Parrye4a9f642014-11-24 16:20:53 -080017This method returns the query result as an array of **objects**, or
Derek Jones8ede1a22011-10-05 13:34:52 -050018**an empty array** on failure. Typically you'll use this in a foreach
19loop, like this::
20
Joseph Wensleyf24f4042011-10-06 22:53:29 -040021 $query = $this->db->query("YOUR QUERY");
Andrey Andreev10b6e7a2015-07-24 12:38:58 +030022
Joseph Wensleyf24f4042011-10-06 22:53:29 -040023 foreach ($query->result() as $row)
24 {
25 echo $row->title;
26 echo $row->name;
27 echo $row->body;
28 }
Derek Jones8ede1a22011-10-05 13:34:52 -050029
Andrey Andreevab0034b2014-12-11 18:31:51 +020030The above method is an alias of ``result_object()``.
Derek Jones8ede1a22011-10-05 13:34:52 -050031
Andrey Andreev10b6e7a2015-07-24 12:38:58 +030032You can also pass a string to ``result()`` which represents a class to
Derek Jones8ede1a22011-10-05 13:34:52 -050033instantiate for each result object (note: this class must be loaded)
34
35::
36
37 $query = $this->db->query("SELECT * FROM users;");
38
39 foreach ($query->result('User') as $user)
40 {
Andrey Andreevab0034b2014-12-11 18:31:51 +020041 echo $user->name; // access attributes
42 echo $user->reverse_name(); // or methods defined on the 'User' class
Derek Jones8ede1a22011-10-05 13:34:52 -050043 }
44
Andrey Andreevab0034b2014-12-11 18:31:51 +020045**result_array()**
Derek Jones8ede1a22011-10-05 13:34:52 -050046
James L Parrye4a9f642014-11-24 16:20:53 -080047This method returns the query result as a pure array, or an empty
Derek Jones8ede1a22011-10-05 13:34:52 -050048array when no result is produced. Typically you'll use this in a foreach
49loop, like this::
50
Joseph Wensleyf24f4042011-10-06 22:53:29 -040051 $query = $this->db->query("YOUR QUERY");
Andrey Andreev10b6e7a2015-07-24 12:38:58 +030052
Joseph Wensleyf24f4042011-10-06 22:53:29 -040053 foreach ($query->result_array() as $row)
54 {
55 echo $row['title'];
56 echo $row['name'];
57 echo $row['body'];
58 }
Derek Jones8ede1a22011-10-05 13:34:52 -050059
James L Parry014bc892014-11-24 17:14:19 -080060***********
61Result Rows
62***********
63
Andrey Andreevab0034b2014-12-11 18:31:51 +020064**row()**
Derek Jones8ede1a22011-10-05 13:34:52 -050065
James L Parrye4a9f642014-11-24 16:20:53 -080066This method returns a single result row. If your query has more than
Derek Jones8ede1a22011-10-05 13:34:52 -050067one row, it returns only the first row. The result is returned as an
68**object**. Here's a usage example::
69
Joseph Wensleyf24f4042011-10-06 22:53:29 -040070 $query = $this->db->query("YOUR QUERY");
Lonnie Ezell715959d2015-07-22 09:20:05 -050071
72 $row = $query->row();
73
Lonnie Ezell752f5692015-07-23 23:27:01 -050074 if (isset($row))
Joseph Wensleyf24f4042011-10-06 22:53:29 -040075 {
Joseph Wensleyf24f4042011-10-06 22:53:29 -040076 echo $row->title;
77 echo $row->name;
78 echo $row->body;
79 }
Derek Jones8ede1a22011-10-05 13:34:52 -050080
81If you want a specific row returned you can submit the row number as a
82digit in the first parameter::
83
84 $row = $query->row(5);
85
86You can also add a second String parameter, which is the name of a class
87to instantiate the row with::
88
Joseph Wensleyf24f4042011-10-06 22:53:29 -040089 $query = $this->db->query("SELECT * FROM users LIMIT 1;");
sv3tli0d829a5f2015-03-02 17:22:01 +020090 $row = $query->row(0, 'User');
Joseph Wensleyf24f4042011-10-06 22:53:29 -040091
Andrey Andreevab0034b2014-12-11 18:31:51 +020092 echo $row->name; // access attributes
Joseph Wensleyf24f4042011-10-06 22:53:29 -040093 echo $row->reverse_name(); // or methods defined on the 'User' class
Derek Jones8ede1a22011-10-05 13:34:52 -050094
Andrey Andreevab0034b2014-12-11 18:31:51 +020095**row_array()**
Derek Jones8ede1a22011-10-05 13:34:52 -050096
Andrey Andreevab0034b2014-12-11 18:31:51 +020097Identical to the above ``row()`` method, except it returns an array.
Derek Jones8ede1a22011-10-05 13:34:52 -050098Example::
99
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400100 $query = $this->db->query("YOUR QUERY");
Lonnie Ezell715959d2015-07-22 09:20:05 -0500101
102 $row = $query->row_array();
103
Lonnie Ezell752f5692015-07-23 23:27:01 -0500104 if (isset($row))
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400105 {
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400106 echo $row['title'];
107 echo $row['name'];
108 echo $row['body'];
109 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500110
111If you want a specific row returned you can submit the row number as a
112digit in the first parameter::
113
114 $row = $query->row_array(5);
115
116In addition, you can walk forward/backwards/first/last through your
117results using these variations:
118
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400119 | **$row = $query->first_row()**
120 | **$row = $query->last_row()**
121 | **$row = $query->next_row()**
122 | **$row = $query->previous_row()**
Derek Jones8ede1a22011-10-05 13:34:52 -0500123
124By default they return an object unless you put the word "array" in the
125parameter:
126
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400127 | **$row = $query->first_row('array')**
128 | **$row = $query->last_row('array')**
129 | **$row = $query->next_row('array')**
130 | **$row = $query->previous_row('array')**
Derek Jones8ede1a22011-10-05 13:34:52 -0500131
Andrey Andreevab0034b2014-12-11 18:31:51 +0200132.. note:: All the methods above will load the whole result into memory
133 (prefetching). Use ``unbuffered_row()`` for processing large
134 result sets.
Juan Ignacio Bordad981e292012-05-18 18:29:24 -0300135
Andrey Andreevab0034b2014-12-11 18:31:51 +0200136**unbuffered_row()**
Juan Ignacio Bordad981e292012-05-18 18:29:24 -0300137
Andrey Andreev69edc432012-12-04 13:32:16 +0200138This method returns a single result row without prefetching the whole
139result in memory as ``row()`` does. If your query has more than one row,
140it returns the current row and moves the internal data pointer ahead.
Juan Ignacio Bordad981e292012-05-18 18:29:24 -0300141
Derek Jonesce79be02012-06-25 23:23:46 -0700142::
Juan Ignacio Bordad981e292012-05-18 18:29:24 -0300143
144 $query = $this->db->query("YOUR QUERY");
Andrey Andreev10b6e7a2015-07-24 12:38:58 +0300145
Juan Ignacio Bordada7c9e02012-05-19 09:42:40 -0300146 while ($row = $query->unbuffered_row())
Juan Ignacio Bordad981e292012-05-18 18:29:24 -0300147 {
148 echo $row->title;
149 echo $row->name;
150 echo $row->body;
151 }
152
Andrey Andreev69edc432012-12-04 13:32:16 +0200153You can optionally pass 'object' (default) or 'array' in order to specify
154the returned value's type::
155
156 $query->unbuffered_row(); // object
157 $query->unbuffered_row('object'); // object
158 $query->unbuffered_row('array'); // associative array
159
James L Parrye4a9f642014-11-24 16:20:53 -0800160*********************
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500161Custom Result Objects
162*********************
163
Andrey Andreev56d34672015-07-23 14:03:26 +0300164You can have the results returned as an instance of a custom class instead
165of a ``stdClass`` or array, as the ``result()`` and ``result_array()``
166methods allow. This requires that the class is already loaded into memory.
167The object will have all values returned from the database set as properties.
168If these have been declared and are non-public then you should provide a
169``__set()`` method to allow them to be set.
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500170
171Example::
172
173 class User {
Lonnie Ezell25201822015-07-21 21:32:43 -0500174
Andrey Andreev56d34672015-07-23 14:03:26 +0300175 public $id;
176 public $email;
177 public $username;
178
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500179 protected $last_login;
180
181 public function last_login($format)
182 {
Lonnie Ezellabf089a2015-07-22 09:00:37 -0500183 return $this->last_login->format($format);
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500184 }
185
186 public function __set($name, $value)
187 {
Lonnie Ezellabf089a2015-07-22 09:00:37 -0500188 if ($name === 'last_login')
Lonnie Ezellc87a66b2015-07-22 21:48:02 -0500189 {
190 $this->last_login = DateTime::createFromFormat('U', $value);
191 }
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500192 }
193
194 public function __get($name)
195 {
196 if (isset($this->$name))
197 {
198 return $this->$name;
199 }
200 }
201 }
202
Andrey Andreev56d34672015-07-23 14:03:26 +0300203In addition to the two methods listed below, the following methods also can
204take a class name to return the results as: ``first_row()``, ``last_row()``,
205``next_row()``, and ``previous_row()``.
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500206
207**custom_result_object()**
208
Andrey Andreev56d34672015-07-23 14:03:26 +0300209Returns the entire result set as an array of instances of the class requested.
210The only parameter is the name of the class to instantiate.
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500211
212Example::
213
214 $query = $this->db->query("YOUR QUERY");
215
Lonnie Ezell25201822015-07-21 21:32:43 -0500216 $rows = $query->custom_result_object('User');
217
218 foreach ($rows as $row)
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500219 {
Lonnie Ezell25201822015-07-21 21:32:43 -0500220 echo $row->id;
221 echo $row->email;
222 echo $row->last_login('Y-m-d');
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500223 }
224
225**custom_row_object()**
226
Andrey Andreev56d34672015-07-23 14:03:26 +0300227Returns a single row from your query results. The first parameter is the row
228number of the results. The second parameter is the class name to instantiate.
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500229
230Example::
231
232 $query = $this->db->query("YOUR QUERY");
233
Lonnie Ezellc87a66b2015-07-22 21:48:02 -0500234 $row = $query->custom_row_object(0, 'User');
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500235
Andrey Andreev56d34672015-07-23 14:03:26 +0300236 if (isset($row))
Lonnie Ezellc87a66b2015-07-22 21:48:02 -0500237 {
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500238 echo $row->email; // access attributes
239 echo $row->last_login('Y-m-d'); // access class methods
240 }
241
242You can also use the ``row()`` method in exactly the same way.
243
244Example::
245
Lonnie Ezell25201822015-07-21 21:32:43 -0500246 $row = $query->custom_row_object(0, 'User');
Lonnie Ezellcf3cc1d2015-07-21 10:22:41 -0500247
248*********************
James L Parrye4a9f642014-11-24 16:20:53 -0800249Result Helper Methods
250*********************
Derek Jones8ede1a22011-10-05 13:34:52 -0500251
Andrey Andreevab0034b2014-12-11 18:31:51 +0200252**num_rows()**
Derek Jones8ede1a22011-10-05 13:34:52 -0500253
254The number of rows returned by the query. Note: In this example, $query
255is the variable that the query result object is assigned to::
256
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400257 $query = $this->db->query('SELECT * FROM my_table');
Andrey Andreev10b6e7a2015-07-24 12:38:58 +0300258
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400259 echo $query->num_rows();
Derek Jones8ede1a22011-10-05 13:34:52 -0500260
Andrey Andreevab0034b2014-12-11 18:31:51 +0200261.. note:: Not all database drivers have a native way of getting the total
Andrey Andreevfdb75412012-03-05 16:32:17 +0200262 number of rows for a result set. When this is the case, all of
Andrey Andreevab0034b2014-12-11 18:31:51 +0200263 the data is prefetched and ``count()`` is manually called on the
264 resulting array in order to achieve the same result.
Andrey Andreevfdb75412012-03-05 16:32:17 +0200265
Andrey Andreevab0034b2014-12-11 18:31:51 +0200266**num_fields()**
Derek Jones8ede1a22011-10-05 13:34:52 -0500267
268The number of FIELDS (columns) returned by the query. Make sure to call
James L Parrye4a9f642014-11-24 16:20:53 -0800269the method using your query result object::
Derek Jones8ede1a22011-10-05 13:34:52 -0500270
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400271 $query = $this->db->query('SELECT * FROM my_table');
Andrey Andreev10b6e7a2015-07-24 12:38:58 +0300272
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400273 echo $query->num_fields();
Derek Jones8ede1a22011-10-05 13:34:52 -0500274
Andrey Andreevab0034b2014-12-11 18:31:51 +0200275**free_result()**
Derek Jones8ede1a22011-10-05 13:34:52 -0500276
277It frees the memory associated with the result and deletes the result
278resource ID. Normally PHP frees its memory automatically at the end of
279script execution. However, if you are running a lot of queries in a
280particular script you might want to free the result after each query
Andrey Andreevab0034b2014-12-11 18:31:51 +0200281result has been generated in order to cut down on memory consumption.
282
Derek Jones8ede1a22011-10-05 13:34:52 -0500283Example::
284
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400285 $query = $this->db->query('SELECT title FROM my_table');
Andrey Andreev10b6e7a2015-07-24 12:38:58 +0300286
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400287 foreach ($query->result() as $row)
288 {
289 echo $row->title;
290 }
Andrey Andreevab0034b2014-12-11 18:31:51 +0200291
Joseph Wensleyf24f4042011-10-06 22:53:29 -0400292 $query->free_result(); // The $query result object will no longer be available
293
294 $query2 = $this->db->query('SELECT name FROM some_table');
295
296 $row = $query2->row();
297 echo $row->name;
Andrey Andreevfdb75412012-03-05 16:32:17 +0200298 $query2->free_result(); // The $query2 result object will no longer be available
Andrey Andreev69edc432012-12-04 13:32:16 +0200299
James L Parrye4a9f642014-11-24 16:20:53 -0800300**data_seek()**
Andrey Andreev69edc432012-12-04 13:32:16 +0200301
302This method sets the internal pointer for the next result row to be
303fetched. It is only useful in combination with ``unbuffered_row()``.
304
305It accepts a positive integer value, which defaults to 0 and returns
306TRUE on success or FALSE on failure.
307
308::
309
310 $query = $this->db->query('SELECT `field_name` FROM `table_name`');
311 $query->data_seek(5); // Skip the first 5 rows
312 $row = $query->unbuffered_row();
313
314.. note:: Not all database drivers support this feature and will return FALSE.
James L Parry15162192014-12-05 23:40:47 -0800315 Most notably - you won't be able to use it with PDO.
316
317***************
318Class Reference
319***************
320
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200321.. php:class:: CI_DB_result
James L Parry15162192014-12-05 23:40:47 -0800322
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200323 .. php:method:: result([$type = 'object'])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200324
325 :param string $type: Type of requested results - array, object, or class name
326 :returns: Array containing the fetched rows
327 :rtype: array
328
329 A wrapper for the ``result_array()``, ``result_object()``
330 and ``custom_result_object()`` methods.
331
332 Usage: see `Result Arrays`_.
333
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200334 .. php:method:: result_array()
Andrey Andreevab0034b2014-12-11 18:31:51 +0200335
336 :returns: Array containing the fetched rows
337 :rtype: array
338
339 Returns the query results as an array of rows, where each
340 row is itself an associative array.
341
342 Usage: see `Result Arrays`_.
343
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200344 .. php:method:: result_object()
Andrey Andreevab0034b2014-12-11 18:31:51 +0200345
346 :returns: Array containing the fetched rows
347 :rtype: array
348
349 Returns the query results as an array of rows, where each
350 row is an object of type ``stdClass``.
351
352 Usage: see `Result Arrays`_.
353
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200354 .. php:method:: custom_result_object($class_name)
James L Parry15162192014-12-05 23:40:47 -0800355
Andrey Andreevab0034b2014-12-11 18:31:51 +0200356 :param string $class_name: Class name for the resulting rows
357 :returns: Array containing the fetched rows
358 :rtype: array
James L Parry15162192014-12-05 23:40:47 -0800359
Andrey Andreevab0034b2014-12-11 18:31:51 +0200360 Returns the query results as an array of rows, where each
361 row is an instance of the specified class.
362
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200363 .. php:method:: row([$n = 0[, $type = 'object']])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200364
365 :param int $n: Index of the query results row to be returned
366 :param string $type: Type of the requested result - array, object, or class name
367 :returns: The requested row or NULL if it doesn't exist
368 :rtype: mixed
369
370 A wrapper for the ``row_array()``, ``row_object() and
371 ``custom_row_object()`` methods.
372
373 Usage: see `Result Rows`_.
374
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200375 .. php:method:: unbuffered_row([$type = 'object'])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200376
377 :param string $type: Type of the requested result - array, object, or class name
378 :returns: Next row from the result set or NULL if it doesn't exist
379 :rtype: mixed
380
381 Fetches the next result row and returns it in the
382 requested form.
383
384 Usage: see `Result Rows`_.
385
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200386 .. php:method:: row_array([$n = 0])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200387
388 :param int $n: Index of the query results row to be returned
389 :returns: The requested row or NULL if it doesn't exist
390 :rtype: array
391
392 Returns the requested result row as an associative array.
393
394 Usage: see `Result Rows`_.
395
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200396 .. php:method:: row_object([$n = 0])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200397
398 :param int $n: Index of the query results row to be returned
399 :returns: The requested row or NULL if it doesn't exist
400 :rtype: stdClass
401
402 Returns the requested result row as an object of type
403 ``stdClass``.
404
405 Usage: see `Result Rows`_.
James L Parry15162192014-12-05 23:40:47 -0800406
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200407 .. php:method:: custom_row_object($n, $type)
James L Parry15162192014-12-05 23:40:47 -0800408
409 :param int $n: Index of the results row to return
Andrey Andreevab0034b2014-12-11 18:31:51 +0200410 :param string $class_name: Class name for the resulting row
411 :returns: The requested row or NULL if it doesn't exist
James L Parry15162192014-12-05 23:40:47 -0800412 :rtype: $type
413
Andrey Andreevab0034b2014-12-11 18:31:51 +0200414 Returns the requested result row as an instance of the
415 requested class.
James L Parry15162192014-12-05 23:40:47 -0800416
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200417 .. php:method:: data_seek([$n = 0])
James L Parry15162192014-12-05 23:40:47 -0800418
419 :param int $n: Index of the results row to be returned next
Andrey Andreevab0034b2014-12-11 18:31:51 +0200420 :returns: TRUE on success, FALSE on failure
James L Parry15162192014-12-05 23:40:47 -0800421 :rtype: bool
422
423 Moves the internal results row pointer to the desired offset.
James L Parry15162192014-12-05 23:40:47 -0800424
Andrey Andreevab0034b2014-12-11 18:31:51 +0200425 Usage: see `Result Helper Methods`_.
James L Parry15162192014-12-05 23:40:47 -0800426
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200427 .. php:method:: set_row($key[, $value = NULL])
James L Parry15162192014-12-05 23:40:47 -0800428
Andrey Andreevab0034b2014-12-11 18:31:51 +0200429 :param mixed $key: Column name or array of key/value pairs
430 :param mixed $value: Value to assign to the column, $key is a single field name
431 :rtype: void
432
433 Assigns a value to a particular column.
434
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200435 .. php:method:: next_row([$type = 'object'])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200436
437 :param string $type: Type of the requested result - array, object, or class name
438 :returns: Next row of result set, or NULL if it doesn't exist
439 :rtype: mixed
440
441 Returns the next row from the result set.
442
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200443 .. php:method:: previous_row([$type = 'object'])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200444
445 :param string $type: Type of the requested result - array, object, or class name
446 :returns: Previous row of result set, or NULL if it doesn't exist
447 :rtype: mixed
448
449 Returns the previous row from the result set.
James L Parry15162192014-12-05 23:40:47 -0800450
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200451 .. php:method:: first_row([$type = 'object'])
James L Parry15162192014-12-05 23:40:47 -0800452
Andrey Andreevab0034b2014-12-11 18:31:51 +0200453 :param string $type: Type of the requested result - array, object, or class name
454 :returns: First row of result set, or NULL if it doesn't exist
James L Parry15162192014-12-05 23:40:47 -0800455 :rtype: mixed
456
Andrey Andreevab0034b2014-12-11 18:31:51 +0200457 Returns the first row from the result set.
458
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200459 .. php:method:: last_row([$type = 'object'])
Andrey Andreevab0034b2014-12-11 18:31:51 +0200460
461 :param string $type: Type of the requested result - array, object, or class name
462 :returns: Last row of result set, or NULL if it doesn't exist
463 :rtype: mixed
464
465 Returns the last row from the result set.
466
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200467 .. php:method:: num_rows()
Andrey Andreevab0034b2014-12-11 18:31:51 +0200468
469 :returns: Number of rows in the result set
470 :rtype: int
471
472 Returns the number of rows in the result set.
473
474 Usage: see `Result Helper Methods`_.
475
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200476 .. php:method:: num_fields()
Andrey Andreevab0034b2014-12-11 18:31:51 +0200477
478 :returns: Number of fields in the result set
479 :rtype: int
480
481 Returns the number of fields in the result set.
482
483 Usage: see `Result Helper Methods`_.
484
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200485 .. php:method:: field_data()
Andrey Andreevab0034b2014-12-11 18:31:51 +0200486
487 :returns: Array containing field meta-data
488 :rtype: array
489
490 Generates an array of ``stdClass`` objects containing
491 field meta-data.
James L Parry15162192014-12-05 23:40:47 -0800492
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200493 .. php:method:: free_result()
James L Parry15162192014-12-05 23:40:47 -0800494
495 :rtype: void
496
Andrey Andreevab0034b2014-12-11 18:31:51 +0200497 Frees a result set.
James L Parry15162192014-12-05 23:40:47 -0800498
Andrey Andreevab0034b2014-12-11 18:31:51 +0200499 Usage: see `Result Helper Methods`_.
James L Parry15162192014-12-05 23:40:47 -0800500
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200501 .. php:method:: list_fields()
James L Parry15162192014-12-05 23:40:47 -0800502
503 :returns: Array of column names
504 :rtype: array
505
Andrey Andreevab0034b2014-12-11 18:31:51 +0200506 Returns an array containing the field names in the
sv3tli0d829a5f2015-03-02 17:22:01 +0200507 result set.