PageRenderTime 35ms CodeModel.GetById 30ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/joomla/database/iterator/pdo.php

https://gitlab.com/vitaliylukin91/alex-lavka
PHP | 72 lines | 34 code | 4 blank | 34 comment | 6 complexity | d415867ae9f8c6dabd231ed5da9e2f3a MD5 | raw file
 1<?php
 2/**
 3 * @package     Joomla.Platform
 4 * @subpackage  Database
 5 *
 6 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 7 * @license     GNU General Public License version 2 or later; see LICENSE
 8 */
 9
10defined('JPATH_PLATFORM') or die;
11
12/**
13 * PDO database iterator.
14 *
15 * @since  12.1
16 */
17class JDatabaseIteratorPdo extends JDatabaseIterator
18{
19	/**
20	 * Get the number of rows in the result set for the executed SQL given by the cursor.
21	 *
22	 * @return  integer  The number of rows in the result set.
23	 *
24	 * @since   12.1
25	 * @see     Countable::count()
26	 */
27	public function count()
28	{
29		if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
30		{
31			return $this->cursor->rowCount();
32		}
33		else
34		{
35			return 0;
36		}
37	}
38
39	/**
40	 * Method to fetch a row from the result set cursor as an object.
41	 *
42	 * @return  mixed   Either the next row from the result set or false if there are no more rows.
43	 *
44	 * @since   12.1
45	 */
46	protected function fetchObject()
47	{
48		if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
49		{
50			return $this->cursor->fetchObject($this->class);
51		}
52		else
53		{
54			return false;
55		}
56	}
57
58	/**
59	 * Method to free up the memory used for the result set.
60	 *
61	 * @return  void
62	 *
63	 * @since   12.1
64	 */
65	protected function freeResult()
66	{
67		if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
68		{
69			$this->cursor->closeCursor();
70		}
71	}
72}