/** * Select the database to use. * * @param int $db * @return bool */ public function select($db) { try { return $this->connection->select($db); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
/** * Test selecting another database */ public function testSelect() { $this->redis->set('testSelect', 'someValue'); $selected = $this->redis->select(1); $this->assertInternalType('bool', $selected); $this->assertTrue($selected); $this->assertFalse($this->redis->exists('testSelect')); $this->redis->set('testSelect', 'anotherValue'); $this->assertEquals('anotherValue', $this->redis->get('testSelect')); $this->redis->del('testSelect'); $this->assertTrue($this->redis->select(2)); $this->assertEquals('someValue', $this->redis->get('testSelect')); $this->redis->del('testSelect'); }
/** * This method uses the stored connection parameters to connect an instance. * * @param Connection $conn * @return bool */ protected function connectInstance(Connection $conn) { // connect() and pconnect() can throw exceptions, which we just want to treat as connection failures // TODO: really? can they? try { $res = $this->origPersistent ? $conn->pconnect($this->origHost, $this->origPort, $this->origTimeout) : $conn->connect($this->origHost, $this->origPort, $this->origTimeout); } catch (ConnectionError $e) { return false; } if ($this->origDbindex) { $res = $res && $conn->select($this->origDbindex); } return $res; }
/** * Select the database to use. * @param int $db * @return bool */ public function select($db) { $this->appendToLog('SELECT ' . $db); return $this->connection->select($db); }