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

From: Date: Wed, 24 Aug 2016 11:21:58 +0000
Subject: note 119783 added to function.oci-bind-by-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-206380@lists.php.net to get a copy of this message
Example #7 only shows the binding of a small fixed number of values in an IN clause. There is also a way to bind multiple conditions with a variable number of values. <?php $ids = array( 103, 104 ); $conn = oci_pconnect($user, $pass, $tns); // Using ORACLE table() function to get the ids from the subquery $sql = 'SELECT * FROM employees WHERE employee_id IN (SELECT column_value FROM table(:ids))'; $stmt = oci_parse($conn, $sql); // Create collection of numbers. Build in type for strings is ODCIVARCHAR2LIST, but you can also create own types. $idCollection = oci_new_collection($conn, 'ODCINUMBERLIST', 'SYS'); // Maximum length of collections of type ODCINUMBERLIST is 32767, maybe you should check that! foreach ($ids as $id) { $idCollection->append($id); } oci_bind_by_name($stmt, ':ids', $idCollection, -1, SQLT_NTY); oci_execute($stmt, OCI_DEFAULT); oci_fetch_all($stmt, $return); oci_free_statement($stmt); oci_close($conn); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 141.65.129.225 ---- Manual Page -- http://php.net/manual/en/function.oci-bind-by-name.php Edit -- https://master.php.net/note/edit/119783 Del: integrated -- https://master.php.net/note/delete/119783/integrated Del: useless -- https://master.php.net/note/delete/119783/useless Del: bad code -- https://master.php.net/note/delete/119783/bad+code Del: spam -- https://master.php.net/note/delete/119783/spam Del: non-english -- https://master.php.net/note/delete/119783/non-english Del: in docs -- https://master.php.net/note/delete/119783/in+docs Del: other reasons-- https://master.php.net/note/delete/119783 Reject -- https://master.php.net/note/reject/119783 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206380) next »