cvs: pear /MDB2_Schema/docs/examples example.php

From: Date: Sun, 06 Nov 2005 21:05:36 +0000
Subject: cvs: pear /MDB2_Schema/docs/examples example.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36117@lists.php.net to get a copy of this message
arnaud Sun Nov 6 16:05:36 2005 EDT Modified files: /pear/MDB2_Schema/docs/examples example.php Log: add extra debug info better use of the var_dump package if present http://cvs.php.net/diff.php/pear/MDB2_Schema/docs/examples/example.php?r1=1.9&r2=1.10&ty=u Index: pear/MDB2_Schema/docs/examples/example.php diff -u pear/MDB2_Schema/docs/examples/example.php:1.9 pear/MDB2_Schema/docs/examples/example.php:1.10 --- pear/MDB2_Schema/docs/examples/example.php:1.9 Thu Oct 6 04:32:13 2005 +++ pear/MDB2_Schema/docs/examples/example.php Sun Nov 6 16:05:34 2005 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: example.php,v 1.9 2005/10/06 08:32:13 lsmith Exp $ +// $Id: example.php,v 1.10 2005/11/06 21:05:34 arnaud Exp $ // /** @@ -57,6 +57,13 @@ <html> <body> <?php +@include_once 'Var_Dump.php'; +if (class_exists('Var_Dump')) { + $var_dump = array('Var_Dump', 'display'); +} else { + $var_dump = 'var_dump'; +} + $databases = array( 'mysql' => 'MySQL', 'mysqli' => 'MySQLi', @@ -66,12 +73,11 @@ if (isset($_GET['submit']) && $_GET['file'] != '') { require_once 'MDB2/Schema.php'; - @include_once 'Var_Dump.php'; $dsn = $_GET['type'].'://'.$_GET['user'].':'.$_GET['pass'].'@'.$_GET['host'].'/'.$_GET['name']; $schema =& MDB2_Schema::factory($dsn, array('debug' => true, 'log_line_break' => '<br>')); if (PEAR::isError($schema)) { - $error = $schema->getMessage(); + $error = $schema->getMessage() . ' ' . $schema->getUserInfo(); } else { if ($_GET['action']) { set_time_limit(0); @@ -92,16 +98,15 @@ 'output_mode' => 'file', 'output' => $_GET['file'] ); - if (class_exists('Var_Dump')) { - Var_Dump::display($schema->dumpDatabase($dump_config, $dump_what)); - } else { - var_dump($schema->dumpDatabase($dump_config, $dump_what)); - } + $operation = $schema->dumpDatabase($dump_config, $dump_what); + call_user_func($var_dump, $operation); } elseif ($_GET['action'] == 'create') { - if (class_exists('Var_Dump')) { - Var_Dump::display($schema->updateDatabase($_GET['file'], 'old_'.$_GET['file'])); + $operation = $schema->updateDatabase($_GET['file'], 'old_'.$_GET['file']); + if (PEAR::isError($operation)) { + echo $operation->getMessage() . ' ' . $operation->getUserInfo(); + call_user_func($var_dump, $operation); } else { - var_dump($schema->updateDatabase($_GET['file'], 'old_'.$_GET['file'])); + call_user_func($var_dump, $operation); } } else { $error = 'no action selected'; @@ -109,22 +114,14 @@ $warnings = $schema->getWarnings(); if (count($warnings) > 0) { echo('Warnings<br>'); - if (class_exists('Var_Dump')) { - Var_Dump::display($warnings); - } else { - var_dump($warnings); - } + call_user_func($var_dump, $operation); } if ($schema->db->getOption('debug')) { echo('Debug messages<br>'); echo($schema->db->debugOutput().'<br>'); } echo('Database structure<br>'); - if (class_exists('Var_Dump')) { - Var_Dump::display($schema->database_definition); - } else { - var_dump($schema->database_definition); - } + call_user_func($var_dump, $operation); $schema->disconnect(); } }

« previous php.pear.cvs (#36117) next »