ocinewdescriptor

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

Beschreibung

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 desriptors , the methods load , save , and savefile are associated with the descriptor , for BFILE only the load method exists .

Beispiel 1 .








 
?php

 
/

 
*

 
This

 
script

 
demonstrates

 
file

 
upload

 
to

 
LOB

 
columns

 
*

 
The

 
formfield

 
used

 
for

 
this

 
example

 
looks

 
like

 
this

 
*

 
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

 
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"

 
;

 
     }

 
OCIFreeDescriptor($lob)

 
;

 
OCIFreeStatement($stmt)

 
;

 
OCILogoff($conn)

 
;

 
  }

 
?