aboutsummaryrefslogtreecommitdiff
path: root/includes/vendor/aura/sql/src/Iterator/AssocIterator.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/vendor/aura/sql/src/Iterator/AssocIterator.php')
-rw-r--r--includes/vendor/aura/sql/src/Iterator/AssocIterator.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/includes/vendor/aura/sql/src/Iterator/AssocIterator.php b/includes/vendor/aura/sql/src/Iterator/AssocIterator.php
new file mode 100644
index 0000000..ea77a7a
--- /dev/null
+++ b/includes/vendor/aura/sql/src/Iterator/AssocIterator.php
@@ -0,0 +1,49 @@
+<?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 `fetchAssoc()`.
+ *
+ * @package Aura.Sql
+ *
+ */
+class AssocIterator extends AbstractIterator
+{
+ /**
+ *
+ * Constructor.
+ *
+ * @param PDOStatement $statement PDO statement.
+ *
+ */
+ public function __construct(PDOStatement $statement)
+ {
+ $this->statement = $statement;
+ $this->statement->setFetchMode(PDO::FETCH_ASSOC);
+ }
+
+ /**
+ *
+ * Fetches next row from statement.
+ *
+ */
+ public function next()
+ {
+ $this->row = $this->statement->fetch();
+ $this->key = false;
+ if ($this->row !== false) {
+ $this->key = current($this->row);
+ }
+ }
+}