/** * @depends testAddsItem */ public function testSelectsItems() { $result = $this->client->select(array('SelectExpression' => 'select * from ' . $this->domainName, 'ConsistentRead' => true)); $this->assertCount(1, $result['Items']); $this->assertEquals(array('Name' => 'test', 'Attributes' => array(array('Name' => 'b', 'Value' => '2'), array('Name' => 'a', 'Value' => '1'))), $result['Items'][0]); // Ensure that the select iterator works $i = $this->client->getIterator('Select', array('SelectExpression' => 'select * from ' . $this->domainName, 'ConsistentRead' => true)); $this->assertEquals(array(array('Name' => 'test', 'Attributes' => array(array('Name' => 'b', 'Value' => '2'), array('Name' => 'a', 'Value' => '1')))), iterator_to_array($i)); }
/** * {@inheritDoc} */ public function find($storageName, $key) { $select = "select * from {$storageName} where itemName() = '{$key}'"; $iterator = $this->client->select(array('SelectExpression' => $select)); $results = $iterator->get('Items'); if (count($results)) { $result = array_shift($results); $data = array('id' => $result['Name']); foreach ($result['Attributes'] as $attribute) { $data[$attribute['Name']] = $attribute['Value']; } return $data; } throw new NotFoundException(); }