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 scrip efface alors les lignes selectionnées avec ROWID et valide
* l'effacement après chaque groupe de $commitsize lignes.
* (Utilisez avec prudences, 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 effacées...\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 selectionné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.php3" 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 sauvé!\n";
}else{
echo "Impossible de sauver le Blob\n";
}
OCIFreeDescriptor($lob);
OCIFreeStatement($stmt);
OCILogoff($conn);
}
?>
|
|