Runs a transaction

@param $callback

@return $this
495091
public function transaction(\Closure $callback)
    {
        try {
            // Begin the PDO transaction
            $this->pdo->beginTransaction();

            // Get the Transaction class
            $transaction = $this->container->build('\\Pixie\\QueryBuilder\\Transaction', array($this->connection));

            // Call closure
            $callback($transaction);

            // If no errors have been thrown or the transaction wasn't completed within
            // the closure, commit the changes
            $this->pdo->commit();

            return $this;
        } catch (TransactionHaltException $e) {
            // Commit or rollback behavior has been handled in the closure, so exit
            return $this;
        } catch (\Exception $e) {
            // something happened, rollback changes
            $this->pdo->rollBack();
            return $this;
        }
    }
504608
public function run($commands, Closure $callback = null)
    {
        $commands = (array) $commands;
        $commands = implode(' && ', $commands);

        $this->previousStatus = 0;
        $process = new Process($commands);
        $process->setIdleTimeout(60 * 60);
        $process->run(function ($type, $line) use ($callback) {
            $callback($line);
        });

        $this->previousStatus = $process->getExitCode();
    }
125439
public function each(Closure $callback) 
	{
		foreach( $this->attributes as $key => $value ) 
		{
			if( $callback($value, $key) === false ) {
				break;
			}
		}

		return $this;
	}
356145
private function _finally($callback) {
        if ($this->state !== self::PENDING) {
            $callback($this->value);
        }
        return $this;
    }
660278
public function each($callback)
    {
        array_walk($this->array, function($value, $key) use ($callback) {
            $callback($key, $value);
        });

        return $this;
    }
409412
public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            if ($callback($item, $key) === false) {
                break;
            }
        }

        return $this;
    }
603275
public function setCallback($callback)
    {
        if (!is_callable($callback)) {
            throw new Exception\InvalidArgumentException('Invalid callback provided');
        }

        $this->options['callback'] = $callback;
        return $this;
    }
1113008
public function when($callback)
    {
        $this->filters[] = is_callable($callback) ? $callback : function () use ($callback) {
            return $callback;
        };

        return $this;
    }
203725
public <T> T withTransaction(@NotNull TransactionCallback<T> callback) {
        return withTransaction(Propagation.REQUIRED, Isolation.DEFAULT, callback);
    }
664944
public function send($callback)
    {
        if (version_compare(SWOOLE_VERSION, '1.9.22', '<')) {
            throw new Exception('Swoole version must >= 1.9.22');
        }
        \Swoole\Async::exec($this->__command, $callback);
        return $this;
    }
751931
public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            $result = $callback($item, $key);

            if (false === $result) {
                break;
            }

            if (!is_object($item)) {
                $this->items[$key] = $result;
            }
        }

        return $this;
    }
535749
public function resolve($callback)
    {
        // 重置cookie
        $this->cookies = new CookieJar();
        $this->callback = $callback;
        $this->createQRSource();

        return $this;
    }
426454
function run(callable $callback = null) {
        if (isset($this->res))
            return null;
        $this->res = proc_open($this->cmd, $this->descriptor_spec, $this->pipes, $this->cwd, $this->env);
        if ($this->res) {
            $this->stdout = new TcpConnection($this->pipes[1]);
            if (is_callable($this->onMessage))
                $this->stdout->onMessage = function ($conn, $data) {
                    ($this->onMessage)($this, $data);
                };
            if (is_callable($this->onClose))
                $this->stdout->onClose = function () {
                    ($this->onClose)($this);
                };
            stream_set_blocking($this->pipes[0], false);
            if (is_callable($callback))
                $callback($this);
            return true;
        }
        unset ($this->res);
        return false;
    }
977925
public function each(callable $callback)
    {
        if ($this->isCollection()) {
            foreach ($this->data as $val) {
                $callback($this->box($val));
            }
        } else {
            $callback($this->box($this->data));
        }

        return $this;
    }
217257
public function preprocess(callable $callback)
    {
        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getPreprocessor()->register($callback);
        return $this;
    }
750076
public function setCallback($callback)
    {
        // If the provided $value is not a closure, make it one now for easy resolution.
        if (!is_callable($callback)) {
            $callback = function () use ($callback) {
                return $callback;
            };
        }

        if ($this->protected) {
            return $this;
        }

        $this->callback = $callback;

        return $this;
    }
1346008
public static function startTransaction(callable $callback = null)
    {
        static::verifyConnection();

        if (!static::$adapter->getConnection()->inTransaction()) {
            static::$adapter->getConnection()->beginTransaction();
        }

        if (is_callable($callback)) {
            try {
                call_user_func_array($callback, []);

                static::commit();
            } catch (DatabaseException $e) {
                static::rollback();
            }
        }
    }