Last active
August 29, 2015 14:04
-
-
Save dangtrinhnt/9bad6f617b82666fd2ef to your computer and use it in GitHub Desktop.
Get all parent accounts in PowerSchool
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
#! /usr/bin/php | |
<?php | |
echo "\n\n===================== START =====================\n\n"; | |
echo "\n>> Connecting to the Oracle database...\n"; | |
$OracleListener = "my.oracle.com:1521/PSPRODDB"; | |
$OracleUsername = "PS"; | |
$OraclePassword = "MyOraclePasswd"; | |
$conn = oci_connect($OracleUsername, $OraclePassword, $OracleListener); | |
if (!$conn) { | |
$e = oci_error(); | |
echo "Cannot make Oracle connection.\n\n".$Datadump; | |
} | |
$sql = "select a.username, e.emailaddress | |
from pcas_account a inner join pcas_emailcontact e on a.pcas_accountid = e.pcas_accountid"; | |
$stmt = oci_parse($conn,$sql); | |
oci_execute($stmt); | |
echo ">> Looping through the accounts list:\n"; | |
$count = 1; | |
while($rows = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)){ | |
$username = $rows["USERNAME"]; | |
$email = $rows["EMAILADDRESS"]; | |
echo "+++ #" . $count . " - " . $username . "(" . $email . ")\n"; | |
$count++; | |
} | |
echo ">> Closing Oracle connection...\n"; | |
oci_free_statement($stmt); | |
oci_close($conn); | |
echo "\n\n========================= FINISH ===============================\n\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment