PHP.mk документација

oci_result

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.oci-result.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.oci-result.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
oci_result

Референца за `function.oci-result.php` со подобрена типографија и навигација.

function.oci-result.php

oci_result

Класата OCICollection

oci_resultReturns field's value from the fetched row

= NULL

oci_result(resource $statement, string|int $column): mixed

Враќа вредност на полето од добиениот ред column Враќа податоци од oci_fetch().

, тогаш се враќа само подмножеството редови за едно дете барање. За детали за мапирањето на типови на податоци извршено од екстензијата OCI8, видете го

Параметри

statement

column

во тековниот ред, добиен од

Вратени вредности

Може да биде или број на колона (базиран на 1) или име на колона. Случајот на името на колоната мора да биде случајот што Oracle метаподатоците го опишуваат како колона, што е големо за колони создадени без чувствителност на случајот. false при грешка.

Примери

Пример #1 oci_fetch() with oci_result()

<?php

$conn
= oci_connect('hr', 'welcome', 'localhost/XE');
if (!
$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

$sql = 'SELECT location_id, city FROM locations WHERE location_id < 1200';
$stid = oci_parse($conn, $sql);
oci_execute($stid);

while (
oci_fetch($stid)) {
echo
oci_result($stid, 'LOCATION_ID') . " is ";
echo
oci_result($stid, 'CITY') . "<br>\n";
}

// Displays:
// 1000 is Roma
// 1100 is Venice

oci_free_statement($stid);
oci_close($conn);

?>

Види Исто така

  • oci_fetch_array() - Враќа следниот ред од барање како асоцијативна или нумеричка низа
  • oci_fetch_assoc() - Враќа следниот ред од барање како асоцијативна низа
  • oci_fetch_object() - Враќа следниот ред од барање како објект
  • oci_fetch_row() - Враќа следниот ред од барањето како нумерички низ
  • oci_fetch_all() - Добива повеќе редови од барање во дводимензионална низа

Белешки од корисници 9 белешки

Враќа сè како низи освен апстрактни типови (ROWIDs, LOBs и FILEs). Враќа
ian at eiloart dot com
OCIResult() requires the column name to be written in capitals, so OCIResult($stmt,"column") won't work, but OCIResult($stmt,"COLUMN") works fine. Hope that helps somebody out
dominic dot standage at revolutionltd dot com
пред 23 години
Note that if you are making multiple table selects, you must specify an alias to each column.

This wont work:
----------------------------------------
$qry = "SELECT A.COL_ONE, B.COL_ONE FROM TABLE1 A, TABLE2 B";
$stmt = OCIParse($conn, $qry);

while(OCIFetch($stmt))
{
    $a = OCIResult($stmt, "A.COL_ONE");
...
----------------------------------------

But this will:
----------------------------------------
$qry = "SELECT A.COL_ONE AS X, B.COL_ONE AS Y FROM TABLE1 A, TABLE2 B";
$stmt = OCIParse($conn, $qry);

while(OCIFetch($stmt))
{
    $a = OCIResult($stmt, "X");
...
----------------------------------------

Regards,
erabbott at NOSPAMterra dot com dot br
20 години пред
I am trying to get a list of the first character of a character string.

SELECT distinct substr(version,1,1) as COL1 FROM SPHVVERS where Version is not null order by 1 

This was working and then failed recently. I think it is because some of the strings now added contain a number as the first character.

I found to get it to work I had to use decode statement. (To_Char did not work )

SELECT distinct decode (substr(version,1,1),'1','?','0','!',substr(version,1,1)) as COL1 FROM SPHVVERS where Version is not null order by 1
luismanuelp at gmail dot com
пред 23 години
FYI--

In order to modify Oracle dates (using NLS_DATE_FORMAT...), you must set $ORACLE_HOME first.  This environmental variable is best set in the server startup script (i.e., ./apachectl)

--
Jim
jthome at fcgov dot com
yasuo_ohgaki at hotmail dot com
As this function gets a 'mixed' variable type for the column index, you may use an integer to represent the column number. In this case, the count is starting from 1 and not from zero.
I am not sure, but I think this method is a bit faster than using the column name.
For an example, see the OCINumCols first example.
shayman at quiver dot com
пред 22 години
if you want to join two tables having both the same column (e.g. 'id') but you don't want to (or cannot) specify all the other fields in these two tables (like erabbott mentioned), you can use:

SELECT t1.*, t2.*, t1.id AS id1, t2.id AS id2 
FROM table1 t1, table2 t2;

Note that this does _not_ work:

SELECT *,t1.id AS id1, t2.id AS id2 
FROM table1 t1, table2 t2;
gabi at gambita dot de
пред 23 години
I am trying to get a list of the first character of a character string.

SELECT distinct substr(version,1,1) as COL1 FROM SPHVVERS where Version is not null order by 1 

This was working and then failed recently. I think it is because some of the strings now added contain a number as the first character.

I found to get it to work I had to use decode statement. (To_Char did not work )

SELECT distinct decode (substr(version,1,1),'1','?','0','!',substr(version,1,1)) as COL1 FROM SPHVVERS where Version is not null order by 1
steve dot hurst at instem-lss dot co dot uk
figroc at gmail dot com
I complained that I couldn't get the time from an Oracle date field.  Joe Brown said:

This is not a PHP bug.

Consider setting NLS_DATE_FORMAT.

The manual states OCIResult() returns everything as a string.
NLS_DATE_FORMAT may not be appropriate for your needs.

There are quite a few places you can set NLS_DATE_FORMAT.
* Environment variables (or windows registry on win32)
* orclSID.ora
* on a per session basis; execute this statement after logon:

$cursor=OCIParse($connection,
 "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
OCIExecute($cursor);
OCIFreeCursor($cursor);
dominic dot standage at revolutionltd dot com
пред 23 години
As in my previous post, the same thing applies when using conversion functions in CLOB columns.

Probably the same thing will occur to any conversion function that you use.

So, this wont work

SELECT ... TO_CHAR(MY_CLOB) ...

$my_clob = OCIResult($stmt,"MY_CLOB");

But this will:

SELECT ... TO_CHAR(MY_CLOB) AS MYC ...

$my_clob = OCIResult($stmt,"MYC");

Best regards.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.