★ wanayoo — archive 1999 http://fr.php.net/manual/function.ocinewdescriptor.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to OCI8
Quick Reference
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this pageDutch version of this pageBrazilian Portuguese version of this page
Korean version of this pageCzech version of this page
OCI8
* OCIDefineByName
* OCIBindByName
* OCILogon
* OCIPLogon
* OCINLogon
* OCILogOff
* OCIExecute
* OCICommit
* OCIRollback
* OCINewDescriptor
* OCIRowCount
* OCINumCols
* OCIResult
* OCIFetch
* OCIFetchInto
* OCIFetchStatement
* OCIColumnIsNULL
* OCIColumnName
* OCIColumnSize
* OCIColumnType
* OCIServerVersion
* OCIStatementType
* OCINewCursor
* OCIFreeStatement
* OCIFreeCursor
* OCIFreeDesc
* OCIParse
* OCIError
* OCIInternalDebug

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: OCINewDescriptor
View the source code for this pageSearch the site



Previous page
 OCIRollback
 Updated
Mon, 08 Jan 2001
OCIRowCount 
Next page


OCINewDescriptor

(PHP 3>= 3.0.7, PHP 4 )

OCINewDescriptor --  Initialize a new empty descriptor LOB/FILE (LOB is default)

Description

string OCINewDescriptor (int connection [, int type])

OCINewDescriptor() Allocates storage to hold descriptors or LOB locators. Valid values for the valid type are OCI_D_FILE, OCI_D_LOB, OCI_D_ROWID. For LOB descriptors, the methods load, save, and savefile are associated with the descriptor, for BFILE only the load method exists. See the second example usage hints.

Example 1. OCINewDescriptor


<?php   
    /* This script is designed to be called from a HTML form.
     * It expects $user, $password, $table, $where, and $commitsize
     * to be passed in from the form.  The script then deletes
     * the selected rows using the ROWID and commits after each
     * set of $commitsize rows. (Use with care, there is no rollback)
     */
    $conn = OCILogon($user, $password);
    $stmt = OCIParse($conn,"select rowid from $table $where");
    $rowid = OCINewDescriptor($conn,OCI_D_ROWID);
    OCIDefineByName($stmt,"ROWID",&$rowid);   
    OCIExecute($stmt);
    while ( OCIFetch($stmt) ) {      
       $nrows = OCIRowCount($stmt);
       $delete = OCIParse($conn,"delete from $table where ROWID = :rid");
       OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID);
       OCIExecute($delete);      
       print "$nrows\n";
       if ( ($nrows % $commitsize) == 0 ) {
           OCICommit($conn);      
       }   
    }
    $nrows = OCIRowCount($stmt);   
    print "$nrows deleted...\n";
    OCIFreeStatement($stmt);  
    OCILogoff($conn);
?>  
     

<?php
    /* This script demonstrates file upload to LOB columns
     * The formfield used for this example looks like this
     * <form action="/old?u=http%3A%2F%2Ffr.php.net%2Fmanual%2Fupload.php3&y=1999" method="post" enctype="multipart/form-data">
     * <input type="file" name="lob_upload">
     * ...
     */
  if(!isset($lob_upload) || $lob_upload == 'none'){
?>
<form action="/old?u=http%3A%2F%2Ffr.php.net%2Fmanual%2Fupload.php3&y=1999" method="post" enctype="multipart/form-data">
Upload file: <input type="file" name="lob_upload"><br>
<input type="submit" value="Upload"> - <input type="reset">
</form>
<?php
  } else {
     // $lob_upload contains the temporary filename of the uploaded file
     $conn = OCILogon($user, $password);
     $lob = OCINewDescriptor($conn, OCI_D_LOB);
     $stmt = OCIParse($conn,"insert into $table (id, the_blob) 
               values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob");
     OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB);
     OCIExecute($stmt);
     if($lob->savefile($lob_upload)){
        OCICommit($conn);
        echo "Blob successfully uploaded\n";
     }else{
        echo "Couldn't upload Blob\n";
     }
     OCIFreeDesc($lob);
     OCIFreeStatement($stmt);
     OCILogoff($conn);
  }
?>
     

 About Notes


Previous page
 OCIRollback
 Updated
Mon, 08 Jan 2001
OCIRowCount 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
France
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.