summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'setup.php')
-rwxr-xr-xsetup.php18
1 files changed, 7 insertions, 11 deletions
diff --git a/setup.php b/setup.php
index fc4e001..78ba8d9 100755
--- a/setup.php
+++ b/setup.php
@@ -1,19 +1,15 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ in 5.3.0
-function echo_and_query($q) {
- global $S;
- echo $q."\n";
- return $S['pdo']->query($q);
-}
+$S['conf']['debug']=true;
$interactive=posix_isatty(STDIN);
$opts=getopt('R');
-$S['pdo']=new PDO('mysql:host='.$conf['sqlhost'], $conf['sqluser'], $conf['sqlpass']);
+$S['pdo']=new PDO('mysql:host='.$S['conf']['sqlhost'], $S['conf']['sqluser'], $S['conf']['sqlpass']);
if (isset($opts['R'])) {
- echo_and_query('DROP DATABASE IF EXISTS `'.$conf['sqldb'].'`');
+ query('DROP DATABASE IF EXISTS `'.$S['conf']['sqldb'].'`');
}
-echo_and_query('CREATE DATABASE IF NOT EXISTS `'.$conf['sqldb'].'`'); // We can add charset and collate here if we want
-echo_and_query('USE `'.$conf['sqldb'].'`');
+query('CREATE DATABASE IF NOT EXISTS `'.$S['conf']['sqldb'].'`'); // We can add charset and collate here if we want
+query('USE `'.$S['conf']['sqldb'].'`');
sql_row_obj::set_pdo_obj($S['pdo']);
foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'sql_row_obj')) {
@@ -24,9 +20,9 @@ foreach (get_declared_classes() as $class) {
unset($r);
$o=new $class(); // TODO this will be static once 5.3.0 is out
if (isset($opts['R'])) {
- echo_and_query($o->drop_table());
+ query($o->drop_table());
}
- echo_and_query($o->create_table());
+ query($o->create_table());
}
do {
if ($user->email) {