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

https://gitlab.com/vitaliylukin91/text · 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. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * PDO database iterator.
  12. *
  13. * @since 12.1
  14. */
  15. class JDatabaseIteratorPdo extends JDatabaseIterator
  16. {
  17. /**
  18. * Get the number of rows in the result set for the executed SQL given by the cursor.
  19. *
  20. * @return integer The number of rows in the result set.
  21. *
  22. * @since 12.1
  23. * @see Countable::count()
  24. */
  25. public function count()
  26. {
  27. if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
  28. {
  29. return $this->cursor->rowCount();
  30. }
  31. else
  32. {
  33. return 0;
  34. }
  35. }
  36. /**
  37. * Method to fetch a row from the result set cursor as an object.
  38. *
  39. * @return mixed Either the next row from the result set or false if there are no more rows.
  40. *
  41. * @since 12.1
  42. */
  43. protected function fetchObject()
  44. {
  45. if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
  46. {
  47. return $this->cursor->fetchObject($this->class);
  48. }
  49. else
  50. {
  51. return false;
  52. }
  53. }
  54. /**
  55. * Method to free up the memory used for the result set.
  56. *
  57. * @return void
  58. *
  59. * @since 12.1
  60. */
  61. protected function freeResult()
  62. {
  63. if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
  64. {
  65. $this->cursor->closeCursor();
  66. }
  67. }
  68. }