The Table Store SDK provides the PutRow, GetRow, UpdateRow, and DeleteRow operations for single-row operations.

PutRow

PutRow

You can call this operation to insert a row of data. If the row does not exist, this operation inserts a row. If the row exists, this operation overwrites it. (This means that all columns and column values of all versions of the existing row are deleted).

When performing PutRow, you can use conditional update to set conditions for the existence of the row or conditions for values in certain columns of the row. For more information, see Conditional update.

Operation
    /**
     * Write a row of data. If the row already exists, the data of the row is overwritten. The number of the consumed capacity units (CUs) is returned.
     * @api
     * @param [] $request Request parameters.
     * @return [] Response. 
     * @throws OTSClientException Indicates that a parameter check error occurs or the server returns a verification error.
     * @throws OTSServerException Indicates that the Table Store server returns an error.
     */
    public function putRow(array $request); 
			
Request format
$result = $client->putRow([
    'table_name' => '<string>', // REQUIRED
    'condition' => [
        'row_existence' => <RowExistence>,   
        'column_condition' => <ColumnCondition>
    ],
    'primary_key' => [                              // REQUIRED
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],  
    'attribute_columns' => [         // REQUIRED
            ['<string>', <ColumnValue>], 
            ['<string>', <ColumnValue>, <ColumnType>],
            ['<string>', <ColumnValue>, <ColumnType>, <integer>]
    ],
    'return_content' => [
        'return_type' => <ReturnType>
    ]
]);

			
Request format description
  • table_name: required. This parameter specifies the name of the table.
  • condition: For more information, see Conditional update.
    • row_existence: the row existence condition.
    • column_condition: the column-based condition.
  • primary_key: required. This parameter specifies the primary key value of the row.
    • The primary key of a table can include multiple primary key columns. The primary key columns are sorted by the order they are added. For example, the primary key structure PRIMARY KEY (A, B, C) is different from PRIMARY KEY (A, C, B). Table Store sorts rows based on the values of all primary key columns.
    • Each item consists of the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType, which is optional).
    • The value of PrimaryKeyValue can be an integer or a string. This parameter can be set to null for an auto-increment primary key column.
    • PrimaryKeyType can be set to PrimaryKeyTypeConst::CONST_INTEGER, PrimaryKeyTypeConst::CONST_STRING, PrimaryKeyTypeConst::CONST_BINARY, or PrimaryKeyTypeConst::CONST_PK_AUTO_INCR, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), BINARY, and PK_AUTO_INCR types. PK_AUTO_INCR indicates the auto-increment column. For more information, see Auto-increment primary key column. If the type is INTEGER or STRING, it can be ignored. Otherwise, the type must be specified.
  • attribute_columns: required. This parameter specifies the column attribute value.
    • Each item consists of the attribute name, attribute value (ColumnValue), column type (ColumnType, which is optional), and timestamp (which is optional).
    • ColumnType can be set to ColumnTypeConst::CONST_INTEGER, ColumnTypeConst::CONST_STRING, ColumnTypeConst::CONST_BINARY, ColumnTypeConst::CONST_BOOLEAN, or ColumnTypeConst::CONST_DOUBLE, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), BINARY, BOOLEAN, and DOUBLE types. If the type is BINARY, it must be specified. Otherwise, the type can be ignored or set to null.
    • The timestamp is a 64-bit integer that represents the version of an attribute. This parameter is optional. If this parameter is not specified, the server time is used.
  • return_content: the content to be returned.
    • return_type: Currently, only this parameter is required.
      • A value of ReturnTypeConst::CONST_PK indicates that the value of the auto-increment primary key column is returned.
Result format
[
    'consumed' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ]
    ],
    'primary_key' => [ 
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],  
    'attribute_columns' => []
]
			
Result format description
  • consumed: the number of CUs consumed by this operation.
    • capacity_unit: the number of read and write CUs consumed.
      • read: the number of read CUs consumed.
      • write: the number of write CUs consumed.
  • primary_key: the primary key value, which is consistent with that in the request. If you set the return type to return the value of the auto-increment primary key, this primary key value is returned.
  • attribute_columns: the attribute value, which is the same as that in the request. It is currently empty.
Example 1

The following code provides an example of how to write a row with 10 attribute columns and write one version of data for each column. The version number (timestamp) is specified by the server.

$attr = array();
for($i = 0; $i < 10; $i++) {
    $attr[] = ['Col'. $i, $i]; 
}
$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_IGNORE, // condition can be set to IGNORE, EXPECT_EXIST, or EXPECT_NOT_EXIST.
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'attribute_columns' => $attr
];
$response = $otsClient->putRow ($request);
			
Example 2

The following code provides an example of how to write a row with 10 attribute columns and write three versions of data for each column. The version number (timestamp) is specified by the client.

$attr = array();
$timestamp = getMicroTime();
for($i = 0; $i < 10; $i++) {
    for($j = 0; $j < 3; $j++) {
        $attr[] = ['Col'. $i, $j, null, $timestamp+$j];
    }
}
$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_IGNORE, // condition can be set to IGNORE, EXPECT_EXIST, or EXPECT_NOT_EXIST.
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'attribute_columns' => $attr
];
$response = $otsClient->putRow ($request);
			
Example 3

The following code provides an example of how to write data if the target row does not exist:

$attr = array();
$timestamp = getMicroTime();
for($i = 0; $i < 10; $i++) {
    for($j = 0; $j < 3; $j++) {
        $attr[] = ['Col'. $i, $j, null, $timestamp+$j];
    }
}
$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_EXPECT_NOT_EXIST, // Configure the condition so that data is written if the target row does not exist.
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'attribute_columns' => $attr
];
$response = $otsClient->putRow ($request);
			
Example 4

The following code provides an example of how to write data if the target row already exists and the value of Col0 is greater than 100:

$attr = array();
$timestamp = getMicroTime();
for($i = 0; $i < 10; $i++) {
    for($j = 0; $j < 3; $j++) {
        $attr[] = ['Col'. $i, $j, null, $timestamp+$j];
    }
}
$request = [
    'table_name' => 'MyTable',
    'condition' => [
        'row_existence' => RowExistenceExpectationConst::CONST_EXPECT_EXIST,// Configure the condition so that data is written if the target row exists.
        'column_condition' => [                  // If the condition is met, the data is updated.
            'column_name' => 'Col0',
            'value' => 100,
            'comparator' => ComparatorTypeConst::CONST_GREATER_THAN
        ]
    ,
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'attribute_columns' => $attr
];
$response = $otsClient->putRow ($request);
			

GetRow

OperationsSummary

The GetRow operation specifies the table name and the primary key of a row. The two possible reading results are as follows:

  • If the row exists, the primary key columns and attribute columns of the row are returned.
  • If the row does not exist, no row is returned and no error is reported.
Operation
    /**
     * Read a row of data.
     * @api
     * @param [] $request Request parameters.
     * @return [] Response. 
     * @throws OTSClientException Indicates that a parameter check error occurs or the server returns a verification error.
     * @throws OTSServerException Indicates that the Table Store server returns an error.
     */
    public function getRow(array $request);
			
Request format
$result = $client->getRow([
    'table_name' => '<string>',                     // REQUIRED
    'primary_key' => [                              // REQUIRED
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ], 
    'max_versions' => <integer>,
    'time_range' => [
        'start_time' => <integer>,
        'end_time' => <integer>,
        'specific_time' => <integer>
    ],
    'start_column' => '<string>',
    'end_column' => '<string>',
    'token' => '<string>',
    'columns_to_get' => [
        '<string>',
        '<string>',
        //...   
    ],
    'column_filter' =>  <ColumnCondition>
]);
			
Request format description
  • table_name: required. This parameter specifies the name of the table.
  • primary_key: required. This parameter specifies the primary key value of the row.
    • The primary key of a table can include multiple primary key columns. The primary key columns are sorted by the order they are added. For example, the primary key structure PRIMARY KEY (A, B, C) is different from PRIMARY KEY (A, C, B). Table Store sorts rows based on the values of all primary key columns.
    • Each item consists of the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType, which is optional).
    • The value of PrimaryKeyValue can be an integer or a string.
    • PrimaryKeyType can be set to PrimaryKeyTypeConst::CONST_INTEGER, PrimaryKeyTypeConst::CONST_STRING, or PrimaryKeyTypeConst::CONST_BINARY, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), and BINARY types. If the type is INTEGER or STRING, it can be ignored. Otherwise, the type must be specified.
  • max_versions: the maximum number of versions from which data is read.
  • time_range: the range of versions from which data is read. For more information, see TimeRange.
    • start_time: the start timestamp, in milliseconds. The minimum and maximum values of the timestamp are 0 and INT64. MAX, respectively. To query data within a range, specify start_time and end_time. The range is a left-closed right-open interval.
    • end_time: the end timestamp, in milliseconds. The minimum and maximum values of the timestamp are 0 and INT64. MAX, respectively.
    • specific_time: the specific timestamp. To query data at a specific time, specify specific_time. You can set either specific_time or [start_time, end_time). The unit of this parameter is millisecond. The minimum and maximum values of the timestamp are 0 and INT64. MAX, respectively.
  • You must specify at least one of max_versions and time_range.
    • If you only specify max_versions, data of up to the specified number of versions is returned from the latest to the earliest.
    • If you only specify time_range, all data within the range is returned.
    • If you specify both max_versions and time_range, data of up to the specified number of versions within the version range is returned from the latest to the earliest.
  • columns_to_get: the set of columns to be read. If you do not specify this parameter, all columns are read.
  • start_column: the start column to be read, which is used for reading wide rows. The returned result includes the start column. The column names are sorted lexicographically. Assume that a table contains columns "a", "b", and "c". If the value of start_column is "b", the reading starts from column "b", and columns "b" and "c" are returned.
  • end_column: the end column to be read, which is used for reading wide rows. The returned result does not include the end column. The column names are sorted lexicographically. Assume that a table contains columns "a", "b", and "c". If the value of end_column is "b", the reading ends at column "b", and column "a" is returned.
  • token: the starting position of a wide row to be read next time. This parameter is currently unavailable.
  • column_filter: the filtering condition. Only rows meeting the condition are returned. This parameter is similar to column_condition in condition. For more information, see Filter.
Result format
[
    'consumed' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ]
    ],
    'primary_key' => [ 
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],  
    'attribute_columns' => [
            ['<string>', <ColumnValue>, <ColumnType>, <integer>]
            ['<string>', <ColumnValue>, <ColumnType>, <integer>]
            ['<string>', <ColumnValue>, <ColumnType>, <integer>]
    ],
    'next_token' => '<string>'
]
			
Result format description
  • consumed: the number of CUs consumed by this operation.
    • capacity_unit: the number of read and write CUs consumed.
      • read: the number of read CUs consumed.
      • write: the number of write CUs consumed.
  • primary_key: the primary key value, which is consistent with that in the request. If you set the return type to return the value of the auto-increment primary key, this primary key value is returned.
  • attribute_columns: the attribute value.
    • Each item consists of the attribute name, attribute value (ColumnValue), attribute type (ColumnType), and timestamp.
    • ColumnType can be set to ColumnTypeConst::CONST_INTEGER, ColumnTypeConst::CONST_STRING, ColumnTypeConst::CONST_BINARY, ColumnTypeConst::CONST_BOOLEAN, or ColumnTypeConst::CONST_DOUBLE, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), BINARY, BOOLEAN, and DOUBLE types.
    • The timestamp is a 64-bit integer that represents the version of an attribute.
    • The attributes in the returned result are sorted by attribute name lexicographically in ascending order. The versions of the attributes are sorted by timestamp in descending order.
    • The order of the columns may be inconsistent with that of columns_to_get in the request.
  • next_token: the starting position of a wide row to be read next time. This parameter is currently unavailable. (This parameter is currently unavailable.)
  • If the row does not exist, the values of primary_key and attribute_columns are empty lists [].
Example 1

The following code provides an example of how to read the latest version of a column in a row:

$request = [
    'table_name' => 'MyTable',
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'max_versions' => 1,                     // Set this parameter so that the latest version is read.
    'columns_to_get' => ['Col0']             // Set the column to be read.
];
$response = $otsClient->getRow ($request);
			

Note:

  • If you query a row of data, the system returns the data in all columns of the row. You can specify columns_to_get to enable the system to return the data in specific columns. For example, if you set columns_to_get to Col0 and Col1, the system only returns the data in Col0 and Col1.

  • Conditional filtering is supported. For example, you can configure the system to return results only when the value of Col0 is greater than 24.

  • When both columns_to_get and column_filter are specified, the system first returns results based on the value of columns_to_get, and then filters the returned columns based on the value of column_filter.

  • When a specified column does not exist, pass_if_missing determines the next action. The default value is true, indicating that the condition is valid if the column does not exist.

Example 2

The following code provides an example of how to set a filter:

$request = [
    'table_name' => 'MyTable',
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'max_versions' => 1,                     // Set this parameter so that the latest version is read.
    'column_filter' => [                     // Set the filter so that a row is returned if the value of Col0 is 0.
        'column_name' => 'Col0',
        'value' => 0,
        'comparator' => ComparatorTypeConst::CONST_EQUAL,
        'pass_if_missing' => false          // If a row does not contain the Col0 column, the row is not returned.
    ]
];
$response = $otsClient->getRow ($request);
			

UpdateRow

UpdateRow

You can call this operation to update a single row of data. If no row exists, a new row is added.

The update operations include writing a column, deleting a column, and deleting a version of a column.

An update operation may be performed in any of the following scenarios:

  • Write a column value without specifying the version. Table Store automatically adds a version number to make sure that the version number is incremented.
  • Write a column value with the specified version. If the column does not have the column value of this version, the data is inserted. Otherwise, the existing value is overwritten.
  • Delete the column values of the specified version.
  • Delete the column values of all versions for the entire column.

When performing UpdateRow, you can use conditional update to set conditions for the existence of the row or conditions for values in certain columns of the row. For more information, see Conditional update.

Operation
    /**
     * Update a row of data.
     * @api
     * @param [] $request Request parameters.
     * @return [] Response. 
     * @throws OTSClientException Indicates that a parameter check error occurs or the server returns a verification error.
     * @throws OTSServerException Indicates that the Table Store server returns an error.
     */
    public function updateRow(array $request);
			
Request format
$result = $client->updateRow([
    'table_name' => '<string>', // REQUIRED
    'condition' => [
        'row_existence' => <RowExistence>,
        'column_condition' => <ColumnCondition>
    ],
    'primary_key' => [                              // REQUIRED
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ], 
    'update_of_attribute_columns' => [         // REQUIRED
        'PUT' => [
            ['<string>', <ColumnValue>], 
            ['<string>', <ColumnValue>, <ColumnType>],
            ['<string>', <ColumnValue>, <ColumnType>, <integer>]
        ],
        'DELETE' => [
            ['<string>', <integer>], 
            ['<string>', <integer>], 
            ['<string>', <integer>], 
            ['<string>', <integer>]
        ],
        'DELETE_ALL' => [
            '<string>',
            '<string>',
            '<string>',
            '<string>'
        ],        
    ],
    'return_content' => [
        'return_type' => <ReturnType>
    ]
]);
			
Request format description
  • table_name: required. This parameter specifies the name of the table.
  • condition: the condition for the operation to take effect. For more information, see Conditional update.
    • row_existence: the row existence condition.
    • column_condition: the column-based condition.
  • primary_key: required. This parameter specifies the primary key value of the row.
    • The primary key of a table can include multiple primary key columns. The primary key columns are sorted by the order they are added. For example, the primary key structure PRIMARY KEY (A, B, C) is different from PRIMARY KEY (A, C, B). Table Store sorts rows based on the values of all primary key columns.
    • Each item consists of the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType, which is optional).
    • The value of PrimaryKeyValue can be an integer or a string.
    • PrimaryKeyType can be set to PrimaryKeyTypeConst::CONST_INTEGER, PrimaryKeyTypeConst::CONST_STRING, or PrimaryKeyTypeConst::CONST_BINARY, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), and BINARY types. If the type is INTEGER or STRING, it can be ignored. Otherwise, the type must be specified.
  • update_of_attribute_columns: the modification on the row attributes. (This parameter is required. If none of the operations is performed, the corresponding item can be ignored.) The update operations are as follows:
    • PUT: indicates that if this column does not exist, a new column is added. If the column exists, it is overwritten. The format is the same as that of attribute_columns in PutRow.
      • Each item consists of the attribute name, attribute value (ColumnValue), column type (ColumnType, which is optional), and timestamp (which is optional).
      • ColumnType can be set to ColumnTypeConst::CONST_INTEGER, ColumnTypeConst::CONST_STRING, ColumnTypeConst::CONST_BINARY, ColumnTypeConst::CONST_BOOLEAN, or ColumnTypeConst::CONST_DOUBLE, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), BINARY, BOOLEAN, and DOUBLE types. If the type is BINARY, it must be specified. Otherwise, the type can be ignored or set to null.
      • The timestamp is a 64-bit integer that represents the version of an attribute. This parameter is optional. If this parameter is not specified, the server time is used.
    • DELETE: indicates that data of the specified version in the column is deleted. The timestamp must be specified.
      • Each item consists of the attribute name and timestamp.
      • The timestamp is a 64-bit integer that represents the attribute of the specified version.
    • DELETE_ALL: indicates that data of all versions in the column is deleted. Note: Deleting all attribute columns of a row is not the same as deleting the row. To delete the row, use the DeleteRow operation.
      • You only need to specify the attribute name.
  • return_content: the content to be returned.
    • return_type: Currently, only this parameter is required.
      • A value of ReturnTypeConst::CONST_PK indicates that the value of the auto-increment primary key column is returned.
Result format
[
    'consumed' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ]
    ],
    'primary_key' => [ 
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],  
    'attribute_columns' => []
]
			
Result format description
  • consumed: the number of CUs consumed by this operation.
    • capacity_unit: the number of read and write CUs consumed.
      • read: the number of read CUs consumed.
      • write: the number of write CUs consumed.
  • primary_key: the primary key value, which is consistent with that in the request. If you set the return type to return the value of the auto-increment primary key, this primary key value is returned.
  • attribute_columns: the attribute value, which is the same as that in the request. It is currently empty.
Example 1

The following code provides an example of how to update several columns, delete the specified version of a column, and delete the specified column:

$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_IGNORE,
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'update_of_attribute_columns' => [
        'PUT' => [                       // Update several columns.
            ['Col0', 100],
            ['Col1', 'Hello'],
            ['Col2', 'a binary', ColumnTypeConst::CONST_BINARY],
            ['Col3', 100, null, 1526418378526]
        ],
        'DELETE' => [                    // Delete a version of a column.
            ['Col10', 1526418378526]
        ],
        'DELETE_ALL' => [
            'Col11'                      // Delete a column.
        ]
    ]
];
$response = $otsClient->updateRow($request);
			

Note:

  • UpdateRow also supports conditional statements.
Example 2

The following code provides an example of how to set update conditions:

$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_IGNORE,
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'condition' => [
        'row_existence' => RowExistenceExpectationConst::CONST_EXPECT_EXIST, // Update the row if it exists.
        'column_filter' => [                                                 // Update the row when the value of Col0 is greater than 100.
            'column_name' => 'Col0',
            'value' => 100,
            'comparator' => ComparatorTypeConst::CONST_GREATER_THAN
        ]
    ],    
    'update_of_attribute_columns' => [
        'PUT' => [                       // Update several columns.
            ['Col0', 100],
            ['Col1', 'Hello'],
            ['Col2', 'a binary', ColumnTypeConst::CONST_BINARY],
            ['Col3', 100, null, 1526418378526]
        ],
        'DELETE' => [                    // Delete a version of a column.
            ['Col10', 1526418378526]
        ],
        'DELETE_ALL' => [
            'Col11'                      // Delete a column.
        ]
    ]
];
			

DeleteRow

DeleteRow

You can call this operation to delete a row. No error is reported regardless of whether the specified row exists.

When performing DeleteRow, you can use conditional update to set conditions for the existence of the row or conditions for values in certain columns of the row. For more information, see Conditional update.

Operation
    /**
     * Delete a row of data.
     * @api
     * @param [] $request Request parameters.
     * @return [] Response. 
     * @throws OTSClientException Indicates that a parameter check error occurs or the server returns a verification error.
     * @throws OTSServerException Indicates that the Table Store server returns an error.
     */
    public function deleteRow(array $request);
			
Request format
$result = $client->deleteRow([
    'table_name' => '<string>', // REQUIRED
    'condition' => [
        'row_existence' => <RowExistence>,
        'column_condition' => <ColumnCondition>
    ],
    'primary_key' => [                              // REQUIRED
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],
    'return_content' => [
        'return_type' => <ReturnType>
    ]
]);
			
Request format description
  • table_name: required. This parameter specifies the name of the table.
  • condition: the condition for the operation to take effect. For more information, see Conditional update.
    • row_existence: the row existence condition.
    • column_condition: the column-based condition.
  • primary_key: required. This parameter specifies the primary key value of the row.
    • The primary key of a table can include multiple primary key columns. The primary key columns are sorted by the order they are added. For example, the primary key structure PRIMARY KEY (A, B, C) is different from PRIMARY KEY (A, C, B). Table Store sorts rows based on the values of all primary key columns.
    • Each item consists of the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType, which is optional).
    • The value of PrimaryKeyValue can be an integer or a string.
    • PrimaryKeyType can be set to PrimaryKeyTypeConst::CONST_INTEGER, PrimaryKeyTypeConst::CONST_STRING, or PrimaryKeyTypeConst::CONST_BINARY, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), and BINARY types. If the type is INTEGER or STRING, it can be ignored. Otherwise, the type must be specified.
  • return_content: the content to be returned.

    • return_type: Currently, only this parameter is required.

      • A value of ReturnTypeConst::CONST_PK indicates that the value of the auto-increment primary key column is returned.

Result format
[
    'consumed' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ]
    ],
    'primary_key' => [
        ['<string>', <PrimaryKeyValue>], 
        ['<string>', <PrimaryKeyValue>],
        ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
    ],
    'attribute_columns' => []
]
			
Result format description
  • consumed: the number of CUs consumed by this operation.
    • capacity_unit: the number of read and write CUs consumed.
      • read: the number of read CUs consumed.
      • write: the number of write CUs consumed.
  • primary_key: the primary key value, which is consistent with that in the request. If you set the return type to return the value of the auto-increment primary key, this primary key value is returned.
  • attribute_columns: the attribute value, which is the same as that in the request. It is currently empty.
Example 1

The following code provides an example of how to delete a row of data:

$request = [
    'table_name' => 'MyTable',
    'condition' => RowExistenceExpectationConst::CONST_IGNORE,
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ],
    'return_content' => [
        'return_type' => ReturnTypeConst::CONST_PK     // Set return_type to ReturnTypeConst::CONST_PK so that the value of the auto-increment primary key column is returned.
    ]
];
$response = $otsClient->deleteRow($request);
			
Example 2

The following code provides an example of how to set deletion conditions:

$request = [
    'table_name' => 'MyTable',
    'condition' => [
        'row_existence' => RowExistenceExpectationConst::CONST_EXPECT_EXIST, // Delete the row if it exists.
        'column_filter' => [          // Delete the row when the value of Col0 is greater than 100.
            'column_name' => 'Col0',
            'value' => 100,
            'comparator' => ComparatorTypeConst::CONST_GREATER_THAN
        ],
    ],
    'primary_key' => [ // The primary key.
        ['PK0', 123],
        ['PK1', 'abc']
    ]
];
$response = $otsClient->deleteRow ($request);