1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
|
<HTML
><HEAD
><TITLE
>Oracle 8 functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Function Reference"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="odbc_statistics"
HREF="function.odbc-statistics.html"><LINK
REL="NEXT"
TITLE="OCIDefineByName"
HREF="function.ocidefinebyname.html"><META
NAME="HTTP_EQUIV"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.odbc-statistics.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ocidefinebyname.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.oci8"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>XLIV. Oracle 8 functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN26734"
></A
><P
> These functions allow you to access Oracle8 and Oracle7 databases.
It uses the Oracle8 Call-Interface (OCI8). You will need the Oracle8
client libraries to use this extension.
</P
><P
> This extension is more flexible than the standard Oracle
extension. It supports binding of global and local PHP variables
to Oracle placeholders, has full LOB, FILE and ROWID support
and allows you to use user-supplied define variables.
</P
><P
> Before using this extension, make sure that you have set up your
oracle environment variables properly for the Oracle user, as well
as your web daemon user. The variables you might need to set are as
follows:
<P
></P
><UL
><LI
><P
> ORACLE_HOME
</P
></LI
><LI
><P
> ORACLE_SID
</P
></LI
><LI
><P
> LD_PRELOAD
</P
></LI
><LI
><P
> LD_LIBRARY_PATH
</P
></LI
><LI
><P
> NLS_LANG
</P
></LI
><LI
><P
> ORA_NLS33
</P
></LI
></UL
>
</P
><P
> After setting up the environment variables for your webserver user,
be sure to also add the webserver user (nobody, www) to the oracle
group.
</P
><P
> <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN26753"
></A
><P
><B
>Example 1. OCI Hints</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> <?php
// by sergo@bacup.ru
// Use option: OCI_DEFAULT for execute command to delay execution
OCIExecute($stmt, OCI_DEFAULT);
// for retrieve data use (after fetch):
$result = OCIResult($stmt, $n);
if (is_object ($result)) $result = $result->load();
// For INSERT or UPDATE statetment use:
$sql = "insert into table (field1, field2) values (field1 = 'value',
field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save ("some text");
?>
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
</P
><P
> You can easily access stored procedures in the same way as you
would from the commands line.
<TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN26757"
></A
><P
><B
>Example 2. Using Stored Procedures</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> <?php
// by webmaster@remoterealty.com
$sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname',
'$lastname', '$company', '$address1', '$address2', '$city', '$state',
'$postalcode', '$country', :error_code );end;" );
// This calls stored procedure sp_newaddress, with :address_id being an
// in/out variable and :error_code being an out variable.
// Then you do the binding:
OCIBindByName ( $sth, ":address_id", $addr_id, 10 );
OCIBindByName ( $sth, ":error_code", $errorcode, 10 );
OCIExecute ( $sth );
?>
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
</P
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="function.ocidefinebyname.html"
>OCIDefineByName</A
> —
Use a PHP variable for the define-step during a SELECT
</DT
><DT
><A
HREF="function.ocibindbyname.html"
>OCIBindByName</A
> — Bind a PHP variable to an Oracle Placeholder</DT
><DT
><A
HREF="function.ocilogon.html"
>OCILogon</A
> — Establishes a connection to Oracle</DT
><DT
><A
HREF="function.ociplogon.html"
>OCIPLogon</A
> — Connect to an Oracle database and log on using a persistant connection.
Returns a new session.</DT
><DT
><A
HREF="function.ocinlogon.html"
>OCINLogon</A
> — Connect to an Oracle database and log on using a new connection.
Returns a new session.</DT
><DT
><A
HREF="function.ocilogoff.html"
>OCILogOff</A
> — Disconnects from Oracle</DT
><DT
><A
HREF="function.ociexecute.html"
>OCIExecute</A
> — Execute a statement</DT
><DT
><A
HREF="function.ocicommit.html"
>OCICommit</A
> — Commits outstanding transactions</DT
><DT
><A
HREF="function.ocirollback.html"
>OCIRollback</A
> — Rolls back outstanding transactions</DT
><DT
><A
HREF="function.ocinewdescriptor.html"
>OCINewDescriptor</A
> — Initialize a new empty descriptor LOB/FILE (LOB is default)</DT
><DT
><A
HREF="function.ocirowcount.html"
>OCIRowCount</A
> — Gets the number of affected rows</DT
><DT
><A
HREF="function.ocinumcols.html"
>OCINumCols</A
> — Return the number of result columns in a statement</DT
><DT
><A
HREF="function.ociresult.html"
>OCIResult</A
> — Returns coulumn value for fetched row</DT
><DT
><A
HREF="function.ocifetch.html"
>OCIFetch</A
> — Fetches the next row into result-buffer</DT
><DT
><A
HREF="function.ocifetchinto.html"
>OCIFetchInto</A
> — Fetches the next row into result-array</DT
><DT
><A
HREF="function.ocifetchstatement.html"
>OCIFetchStatement</A
> — Fetch all rows of result data into an array.</DT
><DT
><A
HREF="function.ocicolumnisnull.html"
>OCIColumnIsNULL</A
> — test whether a result column is NULL</DT
><DT
><A
HREF="function.ocicolumnsize.html"
>OCIColumnSize</A
> — return result column size</DT
><DT
><A
HREF="function.ociserverversion.html"
>OCIServerVersion</A
> — Return a string containing server version information.</DT
><DT
><A
HREF="function.ocistatementtype.html"
>OCIStatementType</A
> — Return the type of an OCI statement.</DT
><DT
><A
HREF="function.ocinewcursor.html"
>OCINewCursor</A
> — return a new cursor (Statement-Handle) - use this to bind ref-cursors!</DT
><DT
><A
HREF="function.ocifreestatement.html"
>OCIFreeStatement</A
> — Free all resources associated with a statement.</DT
><DT
><A
HREF="function.ocifreecursor.html"
>OCIFreeCursor</A
> — Free all resources associated with a cursor.</DT
><DT
><A
HREF="function.ocifreedesc.html"
>OCIFreeDesc</A
> — Deletes a large object descriptor.</DT
><DT
><A
HREF="function.ocicolumnname.html"
>OCIColumnName</A
> — Returns the name of a column.</DT
><DT
><A
HREF="function.ocicolumntype.html"
>OCIColumnType</A
> — Returns the data type of a column.</DT
><DT
><A
HREF="function.ociparse.html"
>OCIParse</A
> — Parse a query and return a statement</DT
><DT
><A
HREF="function.ocierror.html"
>OCIError</A
> — Return the last error of stmt|conn|global.
If no error happened returns false.
</DT
><DT
><A
HREF="function.ociinternaldebug.html"
>OCIInternalDebug</A
> —
Enables or disables internal debug output. By default it is
disabled
</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.odbc-statistics.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ocidefinebyname.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>odbc_statistics</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>OCIDefineByName</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|