title: How to get row count from DynamoDB (iOS & PHP)?
body: <p>I need help with querying a DynamoDB table to get the count of rows.</p>
  
  <p>Consider, I have a table "Users" with three fields, "UserName", "Password" and "UserType". UserType can be "Admin", "Employee" or @"Guest". Now I want to get the count of "Admin" in the table. In SQL we write the query like this,</p>
  
  <pre><code>SELECT COUNT(*) FROM Users WHERE UserType='Admin'
  </code></pre>
  
  <p>Now I need to do the same using DynamoDB iOS SDK. For now, I am doing it like this.</p>
  
  <pre><code>- (int)adminUsersCount {
      DynamoDBScanRequest *request = [[[DynamoDBScanRequest alloc] initWithTableName:@"Users"] autorelease];
      DynamoDBCondition *condition = [[[DynamoDBCondition alloc] init] autorelease];
      NSMutableArray *attrList = [NSMutableArray arrayWithObject:[[[DynamoDBAttributeValue alloc] initWithS:@"Admin"]] autorelease]];
      condition.attributeValueList = attrList;
      condition.comparisonOperator = @"EQ";
      [request setScanFilterValue:condition forKey:@"UserType"];
      DynamoDBScanResponse *response = [[AmazonClientManager ddb] scan:request];
      return response.items.count;
  }
  </code></pre>
  
  <p>Here I am fetching all the rows to know that count. I know this is not the right way and is really a bad idea. I don't know how to get the count alone without fetching all the rows.</p>
  
  <ol>
  <li>I want to know how to do it in iOS SDK.</li>
  <li>I want to know how to do it in PHP SDK as well.</li>
  </ol>
  
  <p>Thanks. </p>