summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-03-06 17:06:43 +0000
committerlsces <lester@lsces.co.uk>2026-03-06 17:06:43 +0000
commit2c9468df727e9d90f06dd40e2072b3dfef602eaa (patch)
tree72399c521158c00c13e74c2999cf2e68abeb65ca
parentc59e7916c06f60543dce4e35c36bad0caaa6f551 (diff)
downloadilluminate-firebird-2c9468df727e9d90f06dd40e2072b3dfef602eaa.tar.gz
illuminate-firebird-2c9468df727e9d90f06dd40e2072b3dfef602eaa.tar.bz2
illuminate-firebird-2c9468df727e9d90f06dd40e2072b3dfef602eaa.zip
cursor function needed the same treatment as select returning lower case keys in the arrays
-rwxr-xr-xsrc/illuminate/FirebirdConnection.php44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/illuminate/FirebirdConnection.php b/src/illuminate/FirebirdConnection.php
index b279632..5b2a286 100755
--- a/src/illuminate/FirebirdConnection.php
+++ b/src/illuminate/FirebirdConnection.php
@@ -43,7 +43,7 @@ class FirebirdConnection extends DatabaseConnection
/**
* Get a schema builder instance for this connection.
*
- * @return \Firebird\Illuminate\Schema\Builder
+ * @return \Firebird\Illuminate\Schema\FirebirdBuilder
*/
public function getSchemaBuilder(): FirebirdSchemaBuilder
{
@@ -77,7 +77,7 @@ class FirebirdConnection extends DatabaseConnection
/**
* Get a new query builder instance.
*
- * @return \Firebird\IlluminateQuery\FirebirdBuilder
+ * @return \Firebird\Illuminate\Query\FirebirdBuilder
*/
public function query()
{
@@ -158,6 +158,46 @@ class FirebirdConnection extends DatabaseConnection
}
/**
+ * Run a select statement against the database and returns a generator.
+ *
+ * @param string $query
+ * @param array $bindings
+ * @param bool $useReadPdo
+ * @return \Generator<int, \stdClass>
+ */
+ public function cursor($query, $bindings = [], $useReadPdo = true)
+ {
+ $statement = $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
+ if ($this->pretending()) {
+ return [];
+ }
+
+ // First we will create a statement for the query. Then, we will set the fetch
+ // mode and prepare the bindings for the query. Once that's done we will be
+ // ready to execute the query against the database and return the cursor.
+ $statement = $this->prepared($this->getPdoForSelect($useReadPdo)
+ ->prepare($query));
+
+ $this->bindValues(
+ $statement, $this->prepareBindings($bindings)
+ );
+
+ // Next, we'll execute the query against the database and return the statement
+ // so we can return the cursor. The cursor will use a PHP generator to give
+ // back one row at a time without using a bunch of memory to render them.
+ $statement->execute();
+
+ return $statement;
+ });
+
+ while ($record = $statement->fetch()) {
+ $lowerCaseRow = array_change_key_case((array) $record, CASE_LOWER);
+
+ yield (object) $lowerCaseRow;
+ }
+ }
+
+ /**
* Execute a stored procedure.
*
* @param string $procedure