diff --git a/src/Dabble/Result.php b/src/Dabble/Result.php index 86fc50e..a9e49fd 100644 --- a/src/Dabble/Result.php +++ b/src/Dabble/Result.php @@ -329,6 +329,24 @@ public function free() return false; } + /** + * Runs a user-provided callback with the MySQLi_Result object given as + * argument and returns the result, or returns the MySQLi_Result object if + * called without an argument. + * + * @param callable $callback User-provided callback (optional) + * + * @return mixed|MySQLi_Result + */ + public function __invoke($callback = null) + { + if (isset($callback)) { + return call_user_func($callback, $this->result); + } else { + return $this->result; + } + } + /** * Object destructor. */