/** * @return string */ private function getServerString() { if ($this->serverString === null) { $config = $this->dsn->getConfig(); $this->serverString = '--server ' . $config->getVtCtlHost() . ':' . $config->getVtCtlPort(); } return $this->serverString; }
/** * @param Dsn $dsn * * @return DsnDependent * @throws Exception */ public function setDsn(Dsn $dsn) { $this->dsn = $dsn; $keyspace = $dsn->getConfig()->getKeyspace(); if (!$keyspace) { throw new Exception("SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected"); } $this->set(self::PARAM_KEYSPACE, new Parameter(self::PARAM_KEYSPACE, $keyspace)); return $this; }
/** * @param Dsn $dsn * * @return DsnDependent * @throws Exception */ public function setDsn(Dsn $dsn) { $this->dsn = $dsn; $cell = $dsn->getConfig()->getCell(); if (!$cell) { throw new Exception("Cell missing."); } $this->set(self::PARAM_CELL, new Parameter(self::PARAM_CELL, $cell)); return $this; }
/** * @param array $options */ private function connect(array $options) { $config = $this->dsn->getConfig(); $host = $config->getHost(); $port = $config->getPort(); $connectionString = "{$host}:{$port}"; $this->attributes = new Attributes(); $this->vitess = new Vitess($connectionString, $this->attributes); $this->executor = $this->vitess; $this->fetcherFactory = new FetcherFactory(); if ($config->hasVtCtldData()) { $emulator = new Emulator($this->dsn); $this->executor = new Executor($this->vitess, $emulator); } $this->queryAnalyzer = new Analyzer(); $this->paramProcessor = new ParamProcessor(); if (array_key_exists(CorePDO::MYSQL_ATTR_INIT_COMMAND, $options)) { // Vitess doesn't support SET NAMES queries yet // $query = $options[CorePDO::MYSQL_ATTR_INIT_COMMAND]; // $this->vtgateConnection->execute($this->vitessCtx, $query, [], TabletType::MASTER); return; } }