Example #1
0
 /**
  * Resolve the keys into `BatchGetItem` eligible argument.
  * @param string $table The name of the table.
  * @param array  $keys  The keys.
  * @return array
  */
 private function buildBatchKeyArgument($table, $keys)
 {
     $tableDescription = $this->db->createCommand()->describeTable($table)->execute();
     $keySchema = $tableDescription['Table']['KeySchema'];
     if (ArrayHelper::isIndexed($keys)) {
         $isScalar = is_string($keys[0]) || is_numeric($keys[0]);
         if ($isScalar) {
             return $this->buildBatchKeyArgumentFromIndexedArrayOfScalar($keySchema, $keys);
         } elseif (ArrayHelper::isIndexed($keys[0])) {
             return $this->buildBatchKeyArgumentFromIndexedArrayOfIndexedArray($keySchema, $keys);
         } else {
             return $this->buildBatchKeyArgumentFromIndexedArrayOfAssociativeArray($keySchema, $keys);
         }
     } else {
         return $this->buildBatchGetItemFromAssociativeArray($keySchema, $keys);
     }
 }