note 83094 added to function.oci-bind-by-name

From: Date: Fri, 09 May 2008 16:39:58 +0000
Subject: note 83094 added to function.oci-bind-by-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-139220@lists.php.net to get a copy of this message
//Calling Oracle Stored Procedure //I assume that you have a users table and three columns in users table i.e. id, user, email in oracle // For example I made connection in constructor, you can modify as per your requirement. //http://www.devshed.com/c/a/PHP/Understanding-Destructors-in-PHP-5/1/ <?php class Users{ private $connection; public function __construct() { $this->connection = oci_connect("scott", "tiger", $db); // Establishes a connection to the Oracle server; } public function selectUsers($start_index=1, $numbers_of_rows=20) { $sql ="BEGIN sp_users_select(:p_start_index, :p_numbers_of_rows, :p_cursor, :p_result); END;"; $stmt = oci_parse($this->connection, $sql); //Bind in parameter oci_bind_by_name($stmt, ':p_start_index', $start_index, 20); oci_bind_by_name($stmt, ':p_numbers_of_rows', $numbers_of_rows, 20); //Bind out parameter oci_bind_by_name($stmt, ':p_result', $result, 20); // returns 0 if stored procedure succeessfully executed. //Bind Cursor $p_cursor = oci_new_cursor($this->connection); oci_bind_by_name($stmt, ':p_cursor', $p_cursor, -1, OCI_B_CURSOR); // Execute Statement oci_execute($stmt); oci_execute($p_cursor, OCI_DEFAULT); oci_fetch_all($p_cursor, $cursor, null, null, OCI_FETCHSTATEMENT_BY_ROW); echo $result; echo '<br>'; var_dump($cursor); // $cursor is an associative array so we can use print_r() to print this data. // you can return data from this function to use it at your user interface. } public function deleteUser($id) { $sql ="BEGIN sp_user_delete(:p_id, :p_result); END;"; $stmt = oci_parse($this->connection, $sql); // bind in and out variables oci_bind_by_name($stmt, ':p_id', $id, 20); oci_bind_by_name($stmt, ':p_result', $result, 20); //Execute the statement $check = oci_execute($stmt); if($check == true) $commit = oci_commit($this->connection); else $commit = oci_rollback($this->connection); return $result; } // You can make function for insert ,update using above two functions } ?> ---- Server IP: 203.199.69.133 Probable Submitter: 203.129.203.66 ---- Manual Page -- http://www.php.net/manual/en/function.oci-bind-by-name.php Edit -- https://master.php.net/note/edit/83094 Del: integrated -- https://master.php.net/note/delete/83094/integrated Del: useless -- https://master.php.net/note/delete/83094/useless Del: bad code -- https://master.php.net/note/delete/83094/bad+code Del: spam -- https://master.php.net/note/delete/83094/spam Del: non-english -- https://master.php.net/note/delete/83094/non-english Del: in docs -- https://master.php.net/note/delete/83094/in+docs Del: other reasons-- https://master.php.net/note/delete/83094 Reject -- https://master.php.net/note/reject/83094 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139220) next »