
|
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7">OCINewDescriptor (PHP 3>= 3.0.7, PHP 4 ) OCINewDescriptor --
ç©ºã®æ–°è¦ãƒ‡ã‚£ã‚¹ã‚¯ãƒªãƒ—ã‚¿LOB/FILE(LOBãŒãƒ‡ãƒ•ォルト)ã‚’åˆæœŸåŒ–ã™ã‚‹
説明string OCINewDescriptor ( int connection, int [type])
OCINewDescriptor() ã¯ã€å›ºå®šã—ãŸãƒ‡ã‚£ã‚¹ã‚¯ãƒªãƒ—ã‚¿ã¾ãŸã¯
LOBãƒã‚±ãƒ¼ã‚¿ã«è¨˜æ†¶é ˜åŸŸã‚’確ä¿ã—ã¾ã™ã€‚
type ã§æŒ‡å®šå¯èƒ½ãªå€¤ã¯ã€OCI_D_FILE, OCI_D_LOB,
OCI_D_ROWIDã§ã™ã€‚
LOBディスクリプタã®å ´åˆã€ãƒ¡ã‚½ãƒƒãƒ‰load, save, savefileãŒãƒ‡ã‚£ã‚¹ã‚¯ãƒªãƒ—ã‚¿ã«
関連付ã‘られã¦ã„ã¾ã™ã€‚BFILE ã®å ´åˆã€load メソッドã®ã¿ãŒå˜åœ¨ã—ã¾ã™ã€‚2番目ã®
例ã«ä½¿ç”¨ã®éš›ã®ãƒ’ントを示ã—ã¾ã™ã€‚
例 1OCINewDescriptor <?php
/* ã“ã®ã‚¹ã‚¯ãƒªãƒ—ト㯠HTML フォームã‹ã‚‰ã‚³ãƒ¼ãƒ«ã•ã‚Œã‚‹å‰æã§ä½œæˆ
* ã•れã¦ãŠã‚Šã€$user, $passwor, $table, $where, $commitsize
* ãŒãƒ•ォームã‹ã‚‰æ¸¡ã•れるã“ã¨ã‚’剿ã«ã—ã¦ã„ã¾ã™ã€‚
* ã“ã®ã‚¹ã‚¯ãƒªãƒ—トã¯ã€ROWID を用ã„ã¦é¸æŠžã•れãŸè¡Œã‚’削除ã—ã€
* $commitsize 行毎ã«ã‚³ãƒŸãƒƒãƒˆã—ã¾ã™ã€‚
* (ãƒãƒ¼ãƒ«ãƒãƒƒã‚¯ãŒãªã„ã®ã§ã€æ³¨æ„ã—ã¦ä½¿ç”¨ã—ã¦ãã ã•ã„。)
*/
$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
/* ã“ã®ã‚¹ã‚¯ãƒªãƒ—トやLOB カラムã«ãƒ•ァイルをアップãƒãƒ¼ãƒ‰ã™ã‚‹ä¾‹ã‚’示ã—ã¾ã™ã€‚
* LOBカラムã«ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ã‚’行ã†ã“ã®ä¾‹ã«é–¢ã™ã‚‹ãƒ•ォームã¯ã€
* <form action="upload.php3" method="post" enctype="multipart/form-data">
* <input type="file" name="lob_upload">
* ... ã®ã‚ˆã†ãªã‚‚ã®ãŒä½¿ç”¨ã•れã¾ã™ã€‚
*/
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 ã¯ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ãƒ•ァイルã®ãƒ†ãƒ³ãƒãƒ©ãƒªãƒ•ァイルåを有ã—ã¦ã„ã¾ã™
$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 ã®ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ã¯æˆåŠŸã—ã¾ã—ãŸ\n";
}else{
echo "Blob をアップãƒãƒ¼ãƒ‰ã§ãã¾ã›ã‚“ã§ã—ãŸ\n";
}
OCIFreeDesc($lob);
OCIFreeStatement($stmt);
OCILogoff($conn);
}
?> |
|
例 2OCINewDescriptor <?php
/* Calling PL/SQL stored procedures which contain clobs as input
* parameters (PHP 4 >= 4.0.6).
* Example PL/SQL stored procedure signature is:
*
* PROCEDURE save_data
* Argument Name Type In/Out Default?
* ------------------------------ ----------------------- ------ --------
* KEY NUMBER(38) IN
* DATA CLOB IN
*
*/
$conn = OCILogon($user, $password);
$stmt = OCIParse($conn, "begin save_data(:key, :data); end;");
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName($stmt, ':key', $key);
OCIBindByName($stmt, ':data', $clob, -1, OCI_B_CLOB);
$clob->WriteTemporary($data);
OCIExecute($stmt, OCI_DEFAULT);
OCICommit($conn);
$clob->close();
$clob->free();
OCIFreeStatement($stmt);
?> |
|
|