tarantool-php /
client
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of the tarantool/client package. |
||
| 5 | * |
||
| 6 | * (c) Eugene Leonovich <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Tarantool\Client\Request; |
||
| 15 | |||
| 16 | use Tarantool\Client\Keys; |
||
| 17 | use Tarantool\Client\RequestTypes; |
||
| 18 | |||
| 19 | final class ExecuteRequest implements Request |
||
| 20 | { |
||
| 21 | /** @var non-empty-array<int, int|string|array> */ |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 22 | private $body; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param non-empty-array<int, int|string|array> $body |
||
|
0 ignored issues
–
show
|
|||
| 26 | */ |
||
| 27 | 73 | private function __construct($body) |
|
| 28 | { |
||
| 29 | 73 | $this->body = $body; |
|
| 30 | } |
||
| 31 | |||
| 32 | 65 | public static function fromSql(string $sql, array $params = []) : self |
|
| 33 | { |
||
| 34 | 65 | return new self($params ? [ |
|
| 35 | 65 | Keys::SQL_TEXT => $sql, |
|
| 36 | 65 | Keys::SQL_BIND => $params, |
|
| 37 | 65 | ] : [ |
|
| 38 | 65 | Keys::SQL_TEXT => $sql, |
|
| 39 | 65 | ]); |
|
| 40 | } |
||
| 41 | |||
| 42 | 12 | public static function fromStatementId(int $statementId, array $params = []) : self |
|
| 43 | { |
||
| 44 | 12 | return new self($params ? [ |
|
| 45 | 12 | Keys::STMT_ID => $statementId, |
|
| 46 | 12 | Keys::SQL_BIND => $params, |
|
| 47 | 12 | ] : [ |
|
| 48 | 12 | Keys::STMT_ID => $statementId, |
|
| 49 | 12 | ]); |
|
| 50 | } |
||
| 51 | |||
| 52 | 73 | public function getType() : int |
|
| 53 | { |
||
| 54 | 73 | return RequestTypes::EXECUTE; |
|
| 55 | } |
||
| 56 | |||
| 57 | 73 | public function getBody() : array |
|
| 58 | { |
||
| 59 | 73 | return $this->body; |
|
| 60 | } |
||
| 61 | } |
||
| 62 |