Menu

## Database extends DatabaseHandler
in package

Database.php : 24

Represents an ArangoDB database

##### Tags

author

  Lucas S. Vieira

### Table of Contents

#### Methods

__construct() : mixed
  Database constructor.
create() : bool
  Creates a new database on server
createCollection() : Collection
  Create a new collection on database
current() : array<string|int, mixed>
  Returns information about the current database
drop() : bool
  Drops a database from server
dropCollection() : bool
  Drops a given collection of database
getAllCollections() : ArrayList
  Return all collections of database
getAllGraphs() : ArrayList
  Lists all graphs stored in this database.
getCollection() : Collection|bool
  Return the collection object for a given collection
getConnection() : Connection
  Return the connection object
getDatabaseName() : string
  Return the name of database handled
getGraph() : Graph|false
  Check if database has a given graph
getInfo() : array<string|int, mixed>
  Returns information about the current database
hasCollection() : bool
  Check if database has given collection
list() : ArrayList
  Lists databases that exists on server
setConnection() : void
  Sets a connection for class.
userDatabases() : ArrayList
  Lists the databases that current user has access

### Methods

#### __construct()

Database.php : 61

Database constructor.

`public __construct(Connection $connection) : mixed`

##### Parameters

$connection : Connection

  Connection object to be used

##### Tags

throws
  GuzzleException|DatabaseException|InvalidParameterException|MissingParameterException

#### create()

DatabaseHandler.php : 32

Creates a new database on server

`public static create(Connection $connection, string $database) : bool`

##### Parameters

$connection : Connection

  Connection object to be used

$database : string

  Database name

##### Tags

throws
  GuzzleException|DatabaseException

##### Return values

bool —

True if database was successfully created on server. Throw an exception otherwise.

#### createCollection()

Database.php : 181

Create a new collection on database

`public createCollection(string $collection[, array<string|int, mixed> $attributes = [] ]) : Collection`

##### Parameters

$collection : string

  Collection name

$attributes : array<string|int, mixed> = []

  If you want to specify some custom attribute to collection

##### Tags

throws
  DatabaseException|GuzzleException|InvalidParameterException|MissingParameterException
see
  https://www.arangodb.com/docs/stable/http/collection-creating.html#create-collection

##### Return values

Collection —

A Collection object if operation was successful, throws an exception otherwise

#### current()

DatabaseHandler.php : 139

Returns information about the current database

`public static current(Connection $connection) : array<string|int, mixed>`

##### Parameters

$connection : Connection

  Connection object to be used

##### Tags

throws
  GuzzleException|DatabaseException
see
  https://www.arangodb.com/docs/stable/http/database-database-management.html#information-of-the-database

##### Return values

array<string|int, mixed> —

An array with information about database.

#### drop()

DatabaseHandler.php : 60

Drops a database from server

`public static drop(Connection $connection, string $database) : bool`

##### Parameters

$connection : Connection

  Connection object to be used

$database : string

  Database name

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool —

True if database was successfully dropped on server. Throw an exception otherwise.

#### dropCollection()

Database.php : 228

Drops a given collection of database

`public dropCollection(string $collection) : bool`

##### Parameters

$collection : string

  Collection name

##### Tags

throws
  DatabaseException|GuzzleException|InvalidParameterException|MissingParameterException

##### Return values

bool —

True if operation was successful, false otherwise

#### getAllCollections()

Database.php : 85

Return all collections of database

`public getAllCollections() : ArrayList`

##### Tags

throws
  GuzzleException|DatabaseException|InvalidParameterException|MissingParameterException

##### Return values

ArrayList —

A list with all collections in database.

#### getAllGraphs()

Database.php : 152

Lists all graphs stored in this database.

`public getAllGraphs() : ArrayList`

##### Tags

throws
  DatabaseException|GuzzleException|InvalidParameterException|MissingParameterException|Exception

##### Return values

ArrayList —

A list with all graphs in database.

#### getCollection()

Database.php : 128

Return the collection object for a given collection

`public getCollection(string $collection) : Collection|bool`

##### Parameters

$collection : string

  Collection name

##### Tags

throws
  DatabaseException|GuzzleException|InvalidParameterException|MissingParameterException

##### Return values

Collection|bool —

Collection object. Return False if collection not exists on database

#### getConnection()

ManagesConnection.php : 36

Return the connection object

`public getConnection() : Connection`

##### Return values

Connection

#### getDatabaseName()

Database.php : 73

Return the name of database handled

`public getDatabaseName() : string`

##### Return values

string

#### getGraph()

Database.php : 197

Check if database has a given graph

`public getGraph(string $graph) : Graph|false`

##### Parameters

$graph : string

  Graph name.

##### Tags

throws
  DatabaseException|Exception|GuzzleException|InvalidParameterException|MissingParameterException

##### Return values

Graph|false —

Returns a Graph object if graph exists. Return False if graph not exists on database.

#### getInfo()

Database.php : 243

Returns information about the current database

`public getInfo() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### hasCollection()

Database.php : 100

Check if database has given collection

`public hasCollection(string $collection) : bool`

##### Parameters

$collection : string

  Collection name

##### Tags

throws
  GuzzleException|DatabaseException

##### Return values

bool —

True if operation was successful, false otherwise

#### list()

DatabaseHandler.php : 90

Lists databases that exists on server

`public static list(Connection $connection) : ArrayList`

##### Parameters

$connection : Connection

  Connection object to be used

##### Tags

throws
  GuzzleException|DatabaseException

##### Return values

ArrayList —

A list with all databases on server.

#### setConnection()

ManagesConnection.php : 26

Sets a connection for class.

`public setConnection(Connection $connection) : void`

##### Parameters

$connection : Connection

  Connection object to use.

#### userDatabases()

DatabaseHandler.php : 114

Lists the databases that current user has access

`public static userDatabases(Connection $connection) : ArrayList`

##### Parameters

$connection : Connection

  Connection object to be used

##### Tags

throws
  GuzzleException|DatabaseException

##### Return values

ArrayList —

A list with all databases on server that current user has access.

## Search results