my_conn(); // $sel_stmt = "Select something from somewhere..."; // $conn->my_stmt($sel_stmt); // for ($i=0;$i < $conn->numrows;$i++) // { // print $conn->results["SOMECOLUMNNAME1"][$i]; // print ", "; // print $conn->results["SOMECOLUMNNAME2"][$i]; // } // $conn->my_close(); // (2) // include ("dbconn.php"); // $conn = new mydb; // $sel_stmt = "Select something from somewhere..."; // $conn->my_sel($sel_stmt); // for (.....refer to above) // // (3) (my_sqlbnd) // $sql_stmt = "select * from ineml_route where email_id like // :email"; // $email="seand%"; // $conn = new mydb; // $strarg = "email" . DELIM . $email; // $conn->my_sqlbnd($sql_stmt, $strarg); // print "RETURN: " . $conn->ORA_ERR . " DESC: " . $conn->ORA_ERR_DESC . "\n"; // print "Numrows: " . $conn->numrows . "\n"; // for ($i=0;$i < $conn->numrows;$i++) // { // print $conn->results["CAT_ID"][$i]; // print ", "; // print $conn->results["EMAIL_ID"][$i]; // print "
\n"; // } // // // // // **note no my_close is needed b/c my_sel does it all. var $c; // new connection to mysql db var $sqlstmt; //database object created as result of query var $results; //Results array resulting from any query var $numrows; //Number of rows affected from query var $row; //Row Object containg column values of query var $i; //Current row pointer var $ORA_ERR; //Oracle Error Code var $ORA_ERR_DESC; //Oracle Error Desc. function my_conn() { //Create database connection using bg-id error_reporting(0); $this->i = 0; $this->c = @ocilogon ("sysadm", "oracle") or die ("Could not connect (Bad background connect Userid or Password)"); error_reporting(7); } function my_err() { $err = OCIError($this->sqlstmt); $this->ORA_ERR = $err["code"]; $this->ORA_ERR_DESC = $err["message"]; } function my_sqlbnd() { //Execute bind and sqlstatement, dynamic args. (SQL, VARNAME, VARVALUE, ...) error_reporting(0); $this->my_conn(); $stmt = func_get_arg (0); $this->sqlstmt = @OCIparse($this->c, $stmt); #$numargs = func_num_args(); $strarg = func_get_arg(1); #print "Array string in is: " . $strarg; $args = split(DELIM, $strarg); $numargs = count($args); #print "Array count is: " . $numargs; if ((($numargs) % 2) <> 0) { print "Sorry, invalid # arguments: " . $i . "\n"; } else { for ($i=0;$i<$numargs;$i+=2) { // Get each BIND ARGUMENT and BIND it. $argnme = $args[$i]; $k = $i + 1; // Dynamically create arguement variable and assign value $$argnme = $args[$k]; #print "argnme is: " . $argnme . " value is: (" . $arg[$k] . ")\n"; $bindval = ":" . $argnme; // // The ORACLE error below means you didn't pass SQL with // BIND variables that matched your ARGUEMENTS // OCIBindByName: ORA-01036: illegal variable name // @OCIBindByName($this->sqlstmt,$bindval,&$$argnme,-1); } @OCIexecute($this->sqlstmt); $this->my_err(); if ( eregi('select', $stmt)) { $this->numrows = OCIFetchStatement ($this->sqlstmt, $this->results); } else { $this->numrows = OCIRowCount($this->sqlstmt); } $this->my_close(); } // end if not enough ARGS error_reporting(7); } function my_sel($stmt) { //Execute passed in SQL and Return $results error_reporting(0); $this->my_conn(); $this->sqlstmt = @OCIparse($this->c, $stmt); @OCIexecute($this->sqlstmt); $this->my_err(); if ( eregi('select', $stmt)) { $this->numrows = @OCIFetchStatement ($this->sqlstmt, $this->results); } else { $this->numrows = OCIRowCount($this->sqlstmt); } $this->my_close(); error_reporting(7); } function my_upd($stmt) { //Execute passed in SQL and Return $results error_reporting(0); $this->my_conn(); $this->sqlstmt = @OCIparse($this->c, $stmt); @OCIexecute($this->sqlstmt); $this->my_err(); $this->numrows = OCIRowCount($this->sqlstmt); if ( eregi('insert', $stmt)) { if (( $this->numrows == 0 ) && ( $this->ORA_ERR == 1 )) { print "Insert failed! Try an UPDATE! \n"; } } $this->my_close(); error_reporting(7); } function my_stmt($stmt) { //Execute passed in SQL and Return $results error_reporting(0); $this->sqlstmt = @OCIparse($this->c, $stmt); @OCIexecute($this->sqlstmt); $this->my_err(); if ( eregi('select', $stmt)) { $this->numrows = @OCIFetchStatement ($this->sqlstmt, $this->results); } else { $this->numrows = OCIRowCount($this->sqlstmt); } error_reporting(7); } function my_close() { //Close mysql connection error_reporting(0); @OCIFreeStatement($this->sqlstmt); @OCILogoff($this->c); error_reporting(7); } }//end of class } //end of ifdef statement