Last active
August 29, 2015 14:23
-
-
Save chukShirley/971d8842913b1ac8c5c6 to your computer and use it in GitHub Desktop.
Library list mixup
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 | |
| // Simulate connections to production applications | |
| $db = connectToProduction('ADAM','MYPASS'); | |
| $db = connectToProduction('AS400','MYPASS'); | |
| $db = connectToProduction('CHIP','MYPASS'); | |
| $db = connectToProduction('WEBUSER','WEBUSER'); | |
| $i = 0; | |
| while($i <= 5) { | |
| // Simulate connection to development application | |
| $db = connectToDevelopment(); | |
| $sql = "SELECT ENV FROM LIBTEST"; | |
| $stmt = db2_prepare($db, $sql); | |
| $result = db2_execute($stmt); | |
| $row = db2_fetch_assoc($stmt); | |
| echo $row['ENV']."<br>"; | |
| $i++; | |
| } | |
| function connectToProduction($username, $password) | |
| { | |
| $db = db2_pconnect('*LOCAL', $username, $password, | |
| [ | |
| 'i5_naming' => DB2_I5_NAMING_ON, | |
| 'i5_libl' => 'QS36F', | |
| 'i5_lib' => 'QS36F' | |
| ] | |
| ); | |
| if (!$db){ | |
| throw new Exception('Connection failed'); | |
| } | |
| echo "Production DB connection successful<br>"; | |
| return $db; | |
| } | |
| function connectToDevelopment() | |
| { | |
| $db = db2_pconnect('*LOCAL', 'WEBTEST', 'WEBTEST', | |
| [ | |
| 'i5_naming' => DB2_I5_NAMING_ON, | |
| 'i5_libl' => 'SCRAPTEST', | |
| 'i5_lib' => 'SCRAPTEST' | |
| ] | |
| ); | |
| if (!$db){ | |
| throw new Exception('Connection failed'); | |
| } | |
| echo "Development DB connection successful<br>"; | |
| return $db; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment