forked from ralphschindler/Zend_Db-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-12.php
30 lines (20 loc) · 835 Bytes
/
example-12.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$adapter = include ((file_exists('bootstrap.php')) ? 'bootstrap.php' : 'bootstrap.dist.php');
refresh_data($adapter);
$artistTable = new Zend\Db\TableGateway\TableGateway('artist', $adapter);
// All select()
//
// $artistTable->setSelectResultPrototype(
// new Zend\Db\ResultSet\ResultSet(new Zend\Db\RowGateway\RowGateway($artistTable, 'id'))
// );
// find and update
$rowset = $artistTable->select(array('id' => 2));
// make sure all rows come back and RowGateway
$rowset->setArrayObjectPrototype(new Zend\Db\RowGateway\RowGateway('id', 'artist', $adapter));
$row = $rowset->current();
$row['name'] = 'New Artist'; // array notation
$affected = $row->save();
// check
$rowset = $artistTable->select(array('id' => 2));
$row = $rowset->current();
assert_example_works($row->name == 'New Artist'); // object notation