# Cloud Spanner V1 Client - Class Database (2.9.0)

2.9.0 (latest) 2.8.1 2.7.0 2.6.1 2.5.1 2.4.1 2.3.0 2.2.0 2.1.0 2.0.1-RC1 1.106.0 1.105.1 1.104.1 1.103.0 1.102.0 1.101.0 1.100.0 1.98.0 1.97.0 1.96.0 1.95.0 1.94.0 1.93.1 1.92.1 1.91.0 1.90.0 1.89.0 1.88.0 1.87.0 1.86.0 1.85.0 1.84.0 1.83.0 1.82.0 1.81.0 1.80.0 1.79.0 1.78.0 1.77.0 1.76.1 1.68.0 1.67.0 1.66.0 1.65.0 1.64.0 1.63.2 1.62.1 1.61.0 1.60.0 1.59.0 1.58.4 1.57.0 1.56.0 1.55.0 1.54.2 Reference documentation and code samples for the Cloud Spanner V1 Client class Database.

A Cloud Spanner database.

Generated from protobuf message `google.spanner.admin.database.v1.Database`

## Namespace

Google \\ Cloud \\ Spanner \\ Admin \\ Database \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Required. The name of the database. Values are of the form `projects/<project>/instances/<instance>/databases/<database>`, where `<database>` is as specified in the `CREATE DATABASE` statement. This name can be passed to other API methods to identify the database. |
| `↳ state` | `int` Output only. The current database state. |
| `↳ create_time` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` Output only. If exists, the time at which the database creation started. |
| `↳ restore_info` | `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.RestoreInfo` Output only. Applicable only for restored databases. Contains information about the restore source. |
| `↳ encryption_config` | `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionConfig` Output only. For databases that are using customer managed encryption, this field contains the encryption configuration for the database. For databases that are using Google default or other types of encryption, this field is empty. |
| `↳ encryption_info` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionInfo>` Output only. For databases that are using customer managed encryption, this field contains the encryption information for the database, such as all Cloud KMS key versions that are in use. The `encryption_status' field inside of each`EncryptionInfo\` is not populated. For databases that are using Google default or other types of encryption, this field is empty. This field is propagated lazily from the backend. There might be a delay from when a key version is being used and when it appears in this field. |
| `↳ version_retention_period` | `string` Output only. The period in which Cloud Spanner retains all versions of data for the database. This is the same as the value of version_retention_period database option set using [UpdateDatabaseDdl](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Client.DatabaseAdminClient#_Google_Cloud_Spanner_Admin_Database_V1_Client_DatabaseAdminClient__updateDatabaseDdl__). Defaults to 1 hour, if not set. |
| `↳ earliest_version_time` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` Output only. Earliest timestamp at which older versions of the data can be read. This value is continuously updated by Cloud Spanner and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery. |
| `↳ default_leader` | `string` Output only. The read-write region which contains the database's leader replicas. This is the same as the value of default_leader database option set using DatabaseAdmin.CreateDatabase or DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. |
| `↳ database_dialect` | `int` Output only. The dialect of the Cloud Spanner Database. |
| `↳ enable_drop_protection` | `bool` Whether drop protection is enabled for this database. Defaults to false, if not set. For more details, please see how to [prevent accidental database deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion). |
| `↳ reconciling` | `bool` Output only. If true, the database is being updated. If false, there are no ongoing update operations for the database. |

### getName

Required. The name of the database. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`,
where `<database>` is as specified in the `CREATE DATABASE`
statement. This name can be passed to other API methods to
identify the database.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Required. The name of the database. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`,
where `<database>` is as specified in the `CREATE DATABASE`
statement. This name can be passed to other API methods to
identify the database.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getState

Output only. The current database state.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [State](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Database.State). |

### setState

Output only. The current database state.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [State](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Database.State). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCreateTime

Output only. If exists, the time at which the database creation started.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasCreateTime

### clearCreateTime

### setCreateTime

Output only. If exists, the time at which the database creation started.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRestoreInfo

Output only. Applicable only for restored databases. Contains information
about the restore source.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.RestoreInfo|null` |   |

### hasRestoreInfo

### clearRestoreInfo

### setRestoreInfo

Output only. Applicable only for restored databases. Contains information
about the restore source.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.RestoreInfo` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEncryptionConfig

Output only. For databases that are using customer managed encryption, this
field contains the encryption configuration for the database.

For databases that are using Google default or other types of encryption,
this field is empty.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionConfig|null` |   |

### hasEncryptionConfig

### clearEncryptionConfig

### setEncryptionConfig

Output only. For databases that are using customer managed encryption, this
field contains the encryption configuration for the database.

For databases that are using Google default or other types of encryption,
this field is empty.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionConfig` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEncryptionInfo

Output only. For databases that are using customer managed encryption, this
field contains the encryption information for the database, such as
all Cloud KMS key versions that are in use. The `encryption_status' field
inside of each`EncryptionInfo\` is not populated.

For databases that are using Google default or other types of encryption,
this field is empty.
This field is propagated lazily from the backend. There might be a delay
from when a key version is being used and when it appears in this field.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionInfo>` |   |

### setEncryptionInfo

Output only. For databases that are using customer managed encryption, this
field contains the encryption information for the database, such as
all Cloud KMS key versions that are in use. The `encryption_status' field
inside of each`EncryptionInfo\` is not populated.

For databases that are using Google default or other types of encryption,
this field is empty.
This field is propagated lazily from the backend. There might be a delay
from when a key version is being used and when it appears in this field.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.EncryptionInfo>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getVersionRetentionPeriod

Output only. The period in which Cloud Spanner retains all versions of data
for the database. This is the same as the value of version_retention_period
database option set using
[UpdateDatabaseDdl](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Client.DatabaseAdminClient#_Google_Cloud_Spanner_Admin_Database_V1_Client_DatabaseAdminClient__updateDatabaseDdl__).

Defaults to 1 hour, if not set.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setVersionRetentionPeriod

Output only. The period in which Cloud Spanner retains all versions of data
for the database. This is the same as the value of version_retention_period
database option set using
[UpdateDatabaseDdl](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.Client.DatabaseAdminClient#_Google_Cloud_Spanner_Admin_Database_V1_Client_DatabaseAdminClient__updateDatabaseDdl__).

Defaults to 1 hour, if not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEarliestVersionTime

Output only. Earliest timestamp at which older versions of the data can be
read. This value is continuously updated by Cloud Spanner and becomes stale
the moment it is queried. If you are using this value to recover data, make
sure to account for the time from the moment when the value is queried to
the moment when you initiate the recovery.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasEarliestVersionTime

### clearEarliestVersionTime

### setEarliestVersionTime

Output only. Earliest timestamp at which older versions of the data can be
read. This value is continuously updated by Cloud Spanner and becomes stale
the moment it is queried. If you are using this value to recover data, make
sure to account for the time from the moment when the value is queried to
the moment when you initiate the recovery.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDefaultLeader

Output only. The read-write region which contains the database's leader
replicas.

This is the same as the value of default_leader
database option set using DatabaseAdmin.CreateDatabase or
DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDefaultLeader

Output only. The read-write region which contains the database's leader
replicas.

This is the same as the value of default_leader
database option set using DatabaseAdmin.CreateDatabase or
DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDatabaseDialect

Output only. The dialect of the Cloud Spanner Database.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [DatabaseDialect](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.DatabaseDialect). |

### setDatabaseDialect

Output only. The dialect of the Cloud Spanner Database.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [DatabaseDialect](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/Admin.Database.V1.DatabaseDialect). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEnableDropProtection

Whether drop protection is enabled for this database. Defaults to false,
if not set. For more details, please see how to [prevent accidental
database
deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setEnableDropProtection

Whether drop protection is enabled for this database. Defaults to false,
if not set. For more details, please see how to [prevent accidental
database
deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getReconciling

Output only. If true, the database is being updated. If false, there are no
ongoing update operations for the database.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setReconciling

Output only. If true, the database is being updated. If false, there are no
ongoing update operations for the database.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |