Pheasant\Database\Mysqli\Connection::selectDatabase PHP Method

selectDatabase() public method

Selects a particular database
public selectDatabase ( $database )
    public function selectDatabase($database)
    {
        $mysqli = $this->_mysqli();
        if (!$mysqli->select_db($database)) {
            throw new Exception($mysqli->error, $mysqli->errno);
        }
        $this->_selectedDatabase = $database;
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testSelectNonexistantDatabaseFails()
 {
     $dsn = $this->dsn->copy(array('database' => ''));
     $conn = new Mysqli\Connection($dsn);
     $this->setExpectedException('\\Pheasant\\Database\\Mysqli\\Exception');
     $conn->selectDatabase('llamassddfasdfsdfsdf');
 }