aboutsummaryrefslogtreecommitdiff
path: root/includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php')
-rw-r--r--includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php b/includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php
new file mode 100644
index 0000000..bbd08fc
--- /dev/null
+++ b/includes/vendor/aura/sql/src/Iterator/ObjectsIterator.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ *
+ * This file is part of Aura for PHP.
+ *
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ *
+ */
+namespace Aura\Sql\Iterator;
+
+use PDO;
+use PDOStatement;
+
+/**
+ *
+ * The iterator equivalent of `fetchObjects()`.
+ *
+ * @package Aura.Sql
+ *
+ */
+class ObjectsIterator extends AbstractIterator
+{
+ /**
+ *
+ * Constructor.
+ *
+ * @param PDOStatement $statement PDO statement.
+ *
+ * @param string $class_name The name of the class to create.
+ *
+ * @param array $ctor_args Arguments to pass to the object constructor.
+ *
+ */
+ public function __construct(
+ PDOStatement $statement,
+ $class_name = 'StdClass',
+ array $ctor_args = array()
+ ) {
+ $this->statement = $statement;
+ $this->statement->setFetchMode(PDO::FETCH_CLASS, $class_name);
+ if ($ctor_args) {
+ $this->statement->setFetchMode(
+ PDO::FETCH_CLASS,
+ $class_name,
+ $ctor_args
+ );
+ }
+ }
+
+ /**
+ *
+ * Fetches next row from statement.
+ *
+ */
+ public function next()
+ {
+ $this->row = $this->statement->fetch();
+ $this->key ++;
+ }
+}