Icon edb_changedb

Changes the current database for a connection.

Syntax
edb_changedb(<ConnectionHandle>, <DatabaseName>)

<ConnectionHandle> =

Handle of connection returned by edb_connect function

<DatabaseName> = Valid database name

Returns
TRUE if successful, or FALSE if there are any errors

Usage
The edb_changedb function changes the current database for a connection. This is especially useful when you want to change to the system Configuration database for the purposes of querying system information tables, and then change back to a user-defined database for normal operations.

Examples
<?php

// The following script connects to an ElevateDB
// Server and the system Configuration database,
// creates a new database if it doesn't already exist,
// changes to the new database using the edb_changedb()
// function, and then disconnects using the
// edb_disconnect() function

$con = edb_connect("type=remote;charset=Ansi;address=127.0.0.1;"+
                   "uid=Administrator;pwd=EDBDefault;database=Configuration");
if (!$con)
  {
  die("Could not connect: " . edb_errmsg());
  }
echo edb_db($con);
if (edb_execsql($con,"SELECT * FROM Databases WHERE Name='Tutorial'") == 0)
  {
  edb_execsql($con,"CREATE DATABASE Tutorial PATH 'C:\Tutorial'");
  }
edb_changedb($con,"Tutorial");
echo edb_db($con);
edb_disconnect($con);
?>
Image