finished Table docs
[mdref/mdref-pq-gateway] / pq-gateway / pq / Gateway / Table / create.md
1 # mixed pq\Gateway\Table::create([array $data = NULL[, string $returning = "*"]])
2
3 Create a row in the table.
4
5 ## Params:
6
7 * Optional array $data = NULL
8 The row data.
9 * Optional string $returning = "*"
10 What the INSERT should return.
11
12 ## Returns:
13
14 * a [deferred promise of React/Promise](https://github.com/reactphp/promise#deferred-1), when using pq\Query\AsyncExecutor, the asynchronous executor.
15 Else:
16 * pq\Result, if pq\Result::$status != pq\Result::TUPLES_OK.
17 * pq\Result, if the rowset prototype pq\Gateway\Table::$rowset is empty.
18 * pq\Gateway\Rowset, an instance of the rowset prototype.
19
20
21 ## Example:
22
23 <?php
24
25 use pq\Gateway\Table;
26
27 $accounts = new Table("account");
28 $mike = $accounts->create(["name" => "mike"])->current();
29
30 ?>