Database
extends DatabaseHandler
in package
Represents an ArangoDB database
Tags
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 constructor.
public
__construct(Connection $connection) : mixed
Parameters
- $connection : Connection
-
Connection object to be used
Tags
create()
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
Return values
bool —True if database was successfully created on server. Throw an exception otherwise.
createCollection()
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
Return values
Collection —A Collection object if operation was successful, throws an exception otherwise
current()
Returns information about the current database
public
static current(Connection $connection) : array<string|int, mixed>
Parameters
- $connection : Connection
-
Connection object to be used
Tags
Return values
array<string|int, mixed> —An array with information about database.
drop()
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
Return values
bool —True if database was successfully dropped on server. Throw an exception otherwise.
dropCollection()
Drops a given collection of database
public
dropCollection(string $collection) : bool
Parameters
- $collection : string
-
Collection name
Tags
Return values
bool —True if operation was successful, false otherwise
getAllCollections()
Return all collections of database
public
getAllCollections() : ArrayList
Tags
Return values
ArrayList —A list with all collections in database.
getAllGraphs()
Lists all graphs stored in this database.
public
getAllGraphs() : ArrayList
Tags
Return values
ArrayList —A list with all graphs in database.
getCollection()
Return the collection object for a given collection
public
getCollection(string $collection) : Collection|bool
Parameters
- $collection : string
-
Collection name
Tags
Return values
Collection|bool —Collection object. Return False if collection not exists on database
getConnection()
Return the connection object
public
getConnection() : Connection
Return values
ConnectiongetDatabaseName()
Return the name of database handled
public
getDatabaseName() : string
Return values
stringgetGraph()
Check if database has a given graph
public
getGraph(string $graph) : Graph|false
Parameters
- $graph : string
-
Graph name.
Tags
Return values
Graph|false —Returns a Graph object if graph exists. Return False if graph not exists on database.
getInfo()
Returns information about the current database
public
getInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>hasCollection()
Check if database has given collection
public
hasCollection(string $collection) : bool
Parameters
- $collection : string
-
Collection name
Tags
Return values
bool —True if operation was successful, false otherwise
list()
Lists databases that exists on server
public
static list(Connection $connection) : ArrayList
Parameters
- $connection : Connection
-
Connection object to be used
Tags
Return values
ArrayList —A list with all databases on server.
setConnection()
Sets a connection for class.
public
setConnection(Connection $connection) : void
Parameters
- $connection : Connection
-
Connection object to use.
userDatabases()
Lists the databases that current user has access
public
static userDatabases(Connection $connection) : ArrayList
Parameters
- $connection : Connection
-
Connection object to be used
Tags
Return values
ArrayList —A list with all databases on server that current user has access.