Created
January 15, 2012 16:15
-
-
Save chanmix51/1616300 to your computer and use it in GitHub Desktop.
Show the stored procedures source code using Pomm's API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function help() | |
{ | |
printf("Get the stored procedures source code.\n"); | |
printf("Usage:\n"); | |
printf("show_sp_source schema name\n"); | |
printf("\nname is the stored procedure's name.\n"); | |
printf("schema is the database schema.\n"); | |
printf("environment set the database connection that will be used (default: dev).\n"); | |
exit(1); | |
} | |
if (PHP_SAPI !== 'cli') { | |
throw new \Exception("This is a CLI tool that therefor needs to be launched in a terminal."); | |
} | |
if (count($argv) < 3 or ! preg_match("/^[a-z0-9_]+$/", $argv[1])) { | |
help(); | |
} | |
//$database = SET UP YOUR DATABASE HERE | |
$inspector = new Pomm\Tools\Inspector($database->createConnection()); | |
foreach($inspector->getStoredProcedureSource($argv[1], $argv[2]) as $source) | |
{ | |
printf("==========\n%s\n============\n", $source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment