/**
  * Get Query method
  * @return Query
  */
 public function createQuery()
 {
     $query = new Query();
     $query->using = Query::USING_QUERY;
     $query->from(Customer::tableName());
     return $query;
 }
Esempio n. 2
0
 /**
  * @group getItemsFromResponse
  */
 public function testGetItemsFromResponseOnGetItemResult()
 {
     $query = new Query();
     $query->using = Query::USING_GET_ITEM;
     $response = ['ConsumedCapacity' => [['CapacityUnits' => 10, 'Table' => ['CapacityUnits' => 10], 'TableName' => 'b3cbe4b0-0540-327c-92f1-82dc68be9af5']], 'Item' => ['Barry' => ['S' => 'Sydni'], 'Field2' => ['S' => 'Hello']]];
     $items = $query->getItemsFromResponse($response);
     $this->assertCount(1, $items);
     $peek = array_slice($items, -1)[0];
     $this->assertArraySubset(['_response' => ['ConsumedCapacity' => []]], $peek);
 }
Esempio n. 3
0
 /**
  * @param Connection $db
  * @return ActiveRecord[]
  */
 public function all($db = null)
 {
     $responses = parent::all($db);
     $modelClass = $this->modelClass;
     $marshaller = new \Aws\DynamoDb\Marshaler();
     return array_map(function ($value) use($marshaller) {
         return $this->createModel($value, $marshaller);
     }, $responses[$modelClass::tableName()]);
 }
Esempio n. 4
0
 /**
  * Executes query and returns all results as an array.
  * @param Connection $db The DB connection used to create the DB command.
  * If null, the DB connection returned by [[modelClass]] will be used.
  * @return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.
  */
 public function all($db = null)
 {
     return parent::all($db);
 }