You could go down the OO route. eg...
Class DatabaseConnection {
private $conn;
public function __construct() {
$this->conn = connect();
if (!$this->conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
public function ExecuteQuery( $sql) {
$stid = oci_parse($this->conn, $sql);
oci_execute($stid);
$aResult = oci_fetch_all(...);
oci_close($this->conn);
return $aResult;
}
}
Then your code can just instantiate this class and pass in the sql. So in your script...
$sql = '...';
$oNewDatabaseConnection = new DatabaseConnection();
$aResult = $oNewDatabaseConnection->ExecuteQuery($sql);
If the method of the fetch varies then you can just add some new functions to your class to reflect this.