Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Add the return of the query result as an object for future applications #8448

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ public function fetch_all(object $request): array
return !empty($return) ? $return : [];
}

/**
* {@inheritDoc}
*/
public function fetch_object(object $result, string $class = 'stdClass', array $args = []): object|false|null
{
return mysqli_fetch_object($result, $class, $args);
}

/**
* {@inheritDoc}
*/
Expand Down
8 changes: 8 additions & 0 deletions Sources/Db/APIs/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ public function fetch_all(object $request): array
return !empty($return) ? $return : [];
}

/**
* {@inheritDoc}
*/
public function fetch_object(object $result, string $class = 'stdClass', array $args = []): object|false|null
{
return pg_fetch_object($result, null, $class, $args);
}

/**
* {@inheritDoc}
*/
Expand Down
10 changes: 10 additions & 0 deletions Sources/Db/DatabaseApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function fetch_assoc(object $result): array|false|null;
*/
public function fetch_all(object $request): array;

/**
* Fetches all rows from a result as an object.
*
* @param object $result A query result resource.
* @param string $class The name of the class to instantiate, set the properties of and return. If not specified, a stdClass object is returned.
* @param array $args An optional array of parameters to pass to the constructor for class objects.
* @return object|false|null Returns an object representing the fetched row, where each property represents the name of the result set's column, null if there are no more rows in the result set, or false on failure.
*/
public function fetch_object(object $result, string $class = 'stdClass', array $args = []): object|false|null;

/**
* Frees the memory and data associated with the query result.
*/
Expand Down