cluster()
cluster(string $username, string $password)
Registers cluster management credentials in the container
Parameters
string | $username | admin username |
string | $password | admin password |
Authenticator based on login/password credentials.
This authenticator uses separate credentials for Cluster management interface as well as for each bucket.
<?php $authenticator = new \Couchbase\ClassicAuthenticator(); $authenticator->cluster('Administrator', 'password'); $authenticator->bucket('protected', 'secret'); $cluster = new \Couchbase\Cluster("couchbase://localhost"); $cluster->authenticate($authenticator); $cluster->openBucket('protected'); // successfully opens connection $cluster->manager()->createBucket('hello'); // automatically use admin credentials
<?php $authenticator = new \Couchbase\ClassicAuthenticator(); $authenticator->bucket('people', 'secret'); $authenticator->bucket('orders', '123456'); $cluster = new \Couchbase\Cluster("couchbase://localhost"); $cluster->authenticate($authenticator); $bucket = $cluster->openBucket('orders'); $query = \Couchbase\N1qlQuery::fromString( "SELECT * FROM `orders` JOIN `people` ON KEYS `orders`.person_id ORDER BY `orders`.name"); $query->consistency(\Couchbase\N1qlQuery::REQUEST_PLUS); $query->crossBucket(true); $res = $bucket->query($query); // $res inludes rows from orders and people buckets