//------------------------------------------------------------------
// Get connection to a database. This will only return a new connection
// if there is not one already declared. The static declaration of
// $dbConnection keeps it's value so if it has already been created,
// the existing connection is returned.
function getDBConnection() {
static $dbConnection;
if (is_null($dbConnection) || !isset($dbConnection)) {
try {
$dbConnection = new PDO('ibm:*LOCAL',
UserName, UserPw);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
trigger_error("Error: " . $e->getMessage());
}
}
return $dbConnection;
}
// Executing sql statement:
$sql = 'select count(*) as invCount from shlib.srdsum where oscomp = ? and
osinvc = ? and oscust = ?';
try {
$dbConn = getDBConnection();
$pStmt = $dbConn->prepare($sql);
$pStmt->execute(array($Company, $Invoice, $Customer10));
$row = $pStmt->fetch();
if ($row['INVCOUNT'] == 0)
$okToShow = false;
}
catch (PDOException $e) {
//---Return to Zend Server for IBM i
Users browsing this forum: rees567 and 1 guest