Exemple 1. ocinewdescriptor <?php
/* Ce script est fait pour être appelé dans un formulaire HTML
* Il attends les variables $user, $password, $table, $where, et $commitsize
* Le script efface alors les lignes sélectionnées avec ROWID et valide
* l'effacement après chaque groupe de $commitsize lignes.
* (Utilisez avec prudence, car il n'y a pas d'annulation possible).
*/
$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
/* Ce script est fait pour être appelé depuis un formulaire HTML.
* Il attends les variables $user, $password, $table, $where, et $commitsize,
* données par le formulaire. Le script efface
* les lignes sélectionnées avec ROWID est valide les transactions
* à chaque jeu de $commitsize lignes. (Attention : il n'y plus d'annulation) */
if(!isset($lob_upload) || $lob_upload == 'none'){
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
Fichier à télécharger : <input type="file" name="lob_upload"><br>
<input type="submit" value="Envoyer"> - <input type="reset">
</form>
<?php
} else {
// $lob_upload contains the temporary filename of the uploaded file
// see also the features section on file upload,
// if you would like to use secure uploads
$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, OCI_DEFAULT);
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);
}
?> |
|