function validar($argv, $id, $campo) { if (isset($argv[$id]) && !empty($argv[$id]) && ereg('--[a-zA-Z0-9]*=.*', $argv[$id])) { $validacao = argumentos($argv, $campo); } else { echo "\nVerifique o parâmetro..:{$campo}\n"; exit; } return $validacao; }
<?php include 'functions.php'; include 'bootstrap.php'; // Get the arguments argumentos($argv); $output_directory = '/tmp'; if (isset($args['od'])) { $output_directory = $args['od']; } define('PATH_OUTPUT_DIRECTORY', $output_directory . '/gerador'); $server = isset($args['server']) ? $args['server'] : ''; if (!$server) { echo "Server: "; $server = fgets(STDIN); } if (trim($server) == '' || !isset($server)) { die('Informe server'); } $dbname = isset($args['dbname']) ? $args['dbname'] : ''; $user = isset($args['user']) ? $args['user'] : die('Informe user'); echo "Password: "******"\n"; //echo "Your password was: {$password}.\n"; $connection_string = "host={$server} port=5432 dbname={$dbname} user={$user} password={$password}"; //echo "Connection string: $connection_string\n"; $connection = connect($connection_string); //var_dump($connection); $result_tables = query_tables(); if ($result_tables) {
function validar($argv, $id, $campo) { if (isset($argv[$id]) && ereg('--[a-zA-Z0-9]*=.*', $argv[$id]) && !empty($argv[$id])) { $validacao = argumentos($argv, $campo); } return $validacao; }