-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_firebird_database.php
More file actions
54 lines (46 loc) · 1.45 KB
/
create_firebird_database.php
File metadata and controls
54 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @version $Header$
* @package install
* @subpackage functions
*/
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Added by Lester Caine to provide an in-line generation of Firebird(/Interbase) database
Firebird requires the database to exist before it can be connected to as part of it's
security system
Still need to be extended to allow selection of OS tmp directory,
and path to Firebird bin directory
*/
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 = 16384';
// 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";
if( isset($_ENV["TMP"])) {
$tmp_name = $_ENV["TMP"].'/'.uniqid('').'.sql';
} else {
$tmp_name = '/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);
}
?>