I currently make an Oracle connection like this:
$c = oci_connect('username', 'password', 'host');
which I use my oci8 queries like this:
$s = oci_parse($this->c, $query);
oci_execute($s);
However, every time I want to query, I create a new connection i.e. I do $c = ... many times. This is a silly thing to do. What is the correct or best way to make a single Oracle connection and use that connection from anywhere in the program? I can make $c I global variables but global variables aren’t nice.
Thanks very much :).
Couldn’t you use a static variable, like this…
It still renders your database handle (indirectly) global, but you only ever have one connection, and this way it’s protected from “accidental” update.