1 <?php
2 /**
3 * @package FrameworkOnFramework
4 * @subpackage database
5 * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE.txt
7 *
8 * This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects
9 * instead of plain stdClass objects
10 */
11
12 // Protect from unauthorized access
13 defined('FOF_INCLUDED') or die;
14
15 /**
16 * MySQL database iterator.
17 */
18 class FOFDatabaseIteratorMysql extends FOFDatabaseIterator
19 {
20 /**
21 * Get the number of rows in the result set for the executed SQL given by the cursor.
22 *
23 * @return integer The number of rows in the result set.
24 *
25 * @see Countable::count()
26 */
27 public function count()
28 {
29 return @mysql_num_rows($this->cursor);
30 }
31
32 /**
33 * Method to fetch a row from the result set cursor as an object.
34 *
35 * @return mixed Either the next row from the result set or false if there are no more rows.
36 */
37 protected function fetchObject()
38 {
39 return @mysql_fetch_object($this->cursor, $this->class);
40 }
41
42 /**
43 * Method to free up the memory used for the result set.
44 *
45 * @return void
46 */
47 protected function freeResult()
48 {
49 @mysql_free_result($this->cursor);
50 }
51 }
52