-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnection.php
52 lines (45 loc) · 1.33 KB
/
Connection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace loutrux\orientdb;
use Yii;
use yii\base\Component;
use PhpOrient\PhpOrient;
/**
* Provide a OrientDB client connection from [[Ostico PhpOrient extension]](https://github.com/Ostico/PhpOrient)
*
*
**/
class Connection extends Component
{
public $client;
public $hostname;
public $port;
public $username;
public $password;
public $dbname;
private $clusterMap;
public function __construct($config = [])
{
// ... initialization before configuration is applied
$this->hostname = 'localhost';
$this->port = '2424';
$this->username = 'root';
$this->password = 'root_pass';
parent::__construct($config);
$this->client = new PhpOrient();
$this->client->hostname = $this->hostname;
$this->client->port = $this->port ;
$this->client->username = $this->username;
$this->client->password = $this->password;
$this->client->connect();
if ($this->client->dbExists( $this->dbname))
$this->clusterMap = $this->client->dbOpen( $this->dbname, $this->username, $this->password);
}
public function init()
{
parent::init();
// ... initialization after configuration is applied
}
public function getClusterMap(){
return $this->clusterMap;
}
}