Subject Re: [firebird-php] Create Database file
Author Lester Caine
zaher dirkey wrote:

> How to create database file useing php code.

function FirebirdCreateDB($host, $user, $pass, $dbalias, $fbpath)
{
$sql = 'CREATE DATABASE "'.$host.':'.$dbalias.'"';
if (strlen($user) > 0)
$sql .= ' USER "'.$user.'"';
if (strlen($pass) > 0)
$sql .= ' PASSWORD "'.$pass.'"';
$sql .= ' PAGE_SIZE = 4096';
// if ($s_create_charset != 'NONE') {
// NONE is the default character set
// $sql .= ' DEFAULT CHARACTER SET .$s_create_charset;
// }

$sql .= ';';

$sql = str_replace("\r\n", "\n", $sql);
$sql .= "\n";
$tmp_name = $_ENV["TMP"].'/'.uniqid('').'.sql';

if ($fp = fopen ($tmp_name, 'a')) {
fwrite($fp, $sql);
fclose($fp);
}

$command = sprintf('"%s" -i %s', $fbpath, $tmp_name );
$result = exec($command);
}

--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php