Ejemplo n.º 1
0
 /** Fetches a record by its' passed field and values's */
 function getByID($id = '')
 {
     if ($id != '') {
         $dynamodb = new AmazonDynamoDB();
         $query = array('TableName' => $this->tableName, 'Key' => array('HashKeyElement' => array(AmazonDynamoDB::TYPE_NUMBER => $id)));
         $scan_response = $dynamodb->get_item($query);
         if ($scan_response->status == '200') {
             return $scan_response->body->Item;
         } else {
             print_r($responses);
         }
     }
     return false;
 }
 /**
  * Get an item by id
  * 
  * @param mixed $id
  * @param mixed $consistent
  * @param mixed $attributes
  * @return mixed
  */
 function get($id, $consistent = false, $attributes = null)
 {
     $r = new ddbRequest($this->TableName);
     $r->setKey($id);
     $r->setAttributesToGet($attributes);
     $r->setConsistentRead($consistent);
     $params = $r->getParams();
     $this->response = $this->dynamodb->get_item($params);
     if (!$this->response->isOk()) {
         throw new Exception('Invlaid get operation.');
     }
     return ddbUtil::parse_item($this->response->body->Item);
 }