Mega Code Archive

 
Categories / Php / MySQL Database
 

I thought I would put in an example of the ORACLE BIND

function, because it is so important for websites with heavy traffic. Oracle has a cache that can be re-used for quicker and more efficient queries. If you bind a variable to your SQL query, you can make use of this great feature. Here is a basic example of how this would work: <? $my_bind = "VARIABLE"; /* hopefully you can get this value from an HTTP POST */ PutEnv("ORACLE_HOME=/path/to/ORACLE"); PutEnv("ORACLE_SID=YOUR_ORACLE_SID"); $dbh = ocilogon("username","password","SID"); $sql = "SELECT SOMETHING FROM TABLE WHERE SOME_ID = :media_id "; $sth = ociparse($dbh,$sql); ocibindbyname($sth,":some_id",&$my_bind,6); ociexecute($sth,OCI_DEFAULT); while (ocifetch($sth)) { $my_output = ociresult($sth,1); } ?> By the way... I prefer to leave the '@' symbol off all of my functions. Supressing errors is not necessarily a good thing. 8)