Skip to content

Commit 33f825e

Browse files
committed
updating select
1 parent 7da125d commit 33f825e

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

Diff for: docs/datamapper.md

+46-3
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,12 @@ $insert = $factory->newInsert($connection);
12521252
The `into()` method is used to specify the table to insert data to.
12531253

12541254
```php
1255-
$insert->into('co_invoices');
1255+
$insert
1256+
->into('co_invoices')
1257+
;
1258+
1259+
$insert->perform();
1260+
// INSERT INTO co_invoices
12561261
```
12571262

12581263
##### Columns
@@ -1263,6 +1268,8 @@ $insert
12631268
->into('co_invoices')
12641269
->column('inv_total', 100.12)
12651270
;
1271+
1272+
$insert->perform();
12661273
// INSERT INTO co_invoices (inv_total) VALUES (:inv_total)
12671274
```
12681275

@@ -1275,6 +1282,8 @@ $insert
12751282
->column('inv_total', 100.12);
12761283
->column('inv_status_flag', 0, PDO::PARAM_BOOL)
12771284
;
1285+
1286+
$insert->perform();
12781287
// INSERT INTO co_invoices (
12791288
// inv_cst_id,
12801289
// inv_total,
@@ -1298,6 +1307,8 @@ $insert
12981307
]
12991308
)
13001309
;
1310+
1311+
$insert->perform();
13011312
// INSERT INTO co_invoices (
13021313
// inv_cst_id,
13031314
// inv_total
@@ -1320,6 +1331,8 @@ $insert
13201331
->column('inv_total', 100.12)
13211332
->set('inv_created_date', 'NOW()')
13221333
;
1334+
1335+
$insert->perform();
13231336
// INSERT INTO co_invoices (
13241337
// inv_total,
13251338
// inv_created_date
@@ -1383,7 +1396,7 @@ $insert
13831396
->set('inv_created_date', 'NOW()')
13841397
;
13851398

1386-
echo $insert->getStatement();
1399+
$insert->perform();
13871400
// INSERT INTO co_invoices (
13881401
// inv_cst_id,
13891402
// inv_total,
@@ -1411,7 +1424,7 @@ $insert
14111424
->setFlag('LOW_PRIORITY')
14121425
;
14131426

1414-
echo $insert->getStatement();
1427+
$insert->perform();
14151428
// INSERT LOW_PRIORITY INTO co_invoices (
14161429
// inv_total,
14171430
// inv_created_date
@@ -1452,6 +1465,36 @@ $factory = new QueryFactory();
14521465
$select = $factory->newSelect($connection);
14531466
```
14541467

1468+
#### Execution
1469+
1470+
The [Phalcon\DataMapper\Query\Select][datamapper-query-select] builder acts as a proxy to the [Phalcon\DataMapper\Pdo\Connection][datamapper-pdo-connection] object. As such, the following methods are available, once the query is built:
1471+
1472+
- `fetchAffected()`
1473+
- `fetchAll()`
1474+
- `fetchAssoc()`
1475+
- `fetchCol()`
1476+
- `fetchGroup()`
1477+
- `fetchObject()`
1478+
- `fetchObjects()`
1479+
- `fetchOne()`
1480+
- `fetchPairs()`
1481+
- `fetchValue()`
1482+
1483+
```php
1484+
$records = $select
1485+
->from('co_invoices')
1486+
->columns(['inv_id', 'inv_title'])
1487+
->where('inv_cst_id = 1')
1488+
->fetchAssoc()
1489+
;
1490+
1491+
var_dump($records);
1492+
// [
1493+
// ['inv_id' => 1, 'inv_title' => 'Invoice 1'],
1494+
// ['inv_id' => 2, 'inv_title' => 'Invoice 2'],
1495+
// ]
1496+
```
1497+
14551498
#### Build
14561499

14571500
##### Columns

0 commit comments

Comments
 (0)