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

odbc_fetch_object

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

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

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

function.odbc-fetch-object.php

odbc_fetch_object

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

odbc_fetch_objectЗеми ред од резултат како објект

= NULL

function odbc_fetch_object(Odbc\Result $statement, ?int $row = null): stdClass|false

Преземи object од ODBC прашање.

Параметри

statement

ODBC објектот за резултати од odbc_exec().

row

The 1-based number of the row to retrieve. If omitted or null, the next row of the result set is fetched, as odbc_fetch_row() does. If the driver does not support fetching rows by number, this parameter is ignored.

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

Враќа објект што одговара на добиениот ред, или false ако нема повеќе редови.

Дневник на промени

Верзија = NULL
8.4.0 statement очекува Odbc\Result инстанца сега; претходно, а resource се очекуваше.
8.4.0 row is now nullable, and its default value changed from -1 to null, во согласност со odbc_fetch_row().

Белешки

Забелешка:

Оваа функција постои кога е компајлирана со DBMaker, IBM DB2 или UnixODBC поддршка.

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

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

general na maccrafters dot com
пред 23 години
Here's a bit of code I came up with tha behaves just like mysql_fetch_object()

    function odbc_fetch_object($result)
    {
        $rs=array();
        if(odbc_fetch_into($result,&$rs))
        {
            foreach($rs as $key=>$value)
            {
    $fkey=strtoupper(odbc_field_name($result,$key+1));
                $rs_obj->$fkey = trim($value);

            }
        }
        return($rs_obj);
    }

Special thanks to previous posters for giving me a starting point for this code.
thorsten na rinne dot info
пред 22 години
odbc_fetch_object() works nice with PHP 4.3.3 under W2K with IBM DB2 V.7.2 and V.8.1:

<?php
$conn = odbc_connect($db_name, $username, $password) or die(odbc_error_msg()); 
$sql = "SELECT * FROM TABLE"; 
$result = odbc_exec($conn, $sql);
while ($rows = odbc_fetch_object($result)) { 
    print $rows->COLUMNNAME;
    }
odbc_close($conn); 
?>
Анонимен
пред 5 години
This would be so much more useful if it contained information on what the object returned contains. From var_dump() it seems just an assoc array in object form. But is there column type info, for example?
charlesk na netgaintechnology dot com
пред 23 години
I asked one of the developers to enable this function in the CVS.  I tried it and it worked.  I didnt do anything special.  I was using a Microsoft Access ODBC driver that came with my Windows XP Pro Install. 

I was using the Apache web server.

Charles
kynaston na yahoo dot com
пред 23 години
If you're using Masoud's code in PHP4.2+, change the fifth line to:

odbc_fetch_into($result,&$rs);

(the order of arguments have changed)
j dot a dot z na bluewin dot ch
пред 23 години
hey "general at maccrafters dot com"

thank you very much for your code. it saved me time!
however i extended it a bit!
---------------------------------------------
    function __odbc_fetch_object($res)
    {
        if( function_exists("odbc_fetch_object") )
            return odbc_fetch_object($res);

        $rs = array();
        $rs_obj = false;
        if( odbc_fetch_into($res, &$rs) )
        {
            foreach( $rs as $key=>$value )
            {
                $fkey = odbc_field_name($res, $key+1);
                $rs_obj->$fkey = trim($value);
            }
        }
        return $rs_obj;
    }
---------------------------------------------
cheers, jaz
Marcus dot Karlsson na usa dot net
figroc at gmail dot com
It' possible to get both odbc_fetch_object() and odbc_fetch_array() to work just by removing #ifdef HAVE_DBMAKER/#endif in php_odbc.h line 216 (219) and the same in php_odbc.c line 87 (90) and 1229 (1380).

I've done this sucessfully in the PHP 4.2.0 release using ODBC towards a MySQL database.

I really can't understand why the #ifdef is there from the beginning, but they do have their reasons.

These were the files i "patched"
/* $Id: php_odbc.c,v 1.120.2.1 2002/04/08 22:21:30 sniper Exp $ */
/* $Id: php_odbc.h,v 1.45.2.1 2002/03/12 02:27:47 sniper Exp $ */
masuod_a na hotmail dot com
figroc at gmail dot com
This function not availible in PHP 4.1.1 , you can try this : 

if (function_exists(odbc_fetch_object))
 return;
function odbc_fetch_object($result, $rownumber=1) {
 $rs=array();
 odbc_fetch_into($result, $rownumber,$rs);
 foreach ($rs as $key => $value) {
   $fkey=strtolower(odbc_field_name($result, $key+1));  
   $rs_obj->$fkey = $value;
 }
 return $rs_obj;
}
if you wanna use this function in a loop  you must set rownumber parameter
you can't use this function like :
 while ($myobj=odbc_fetch_object($res)) {
 ....
}
philip
21 години пред
This function requires one of the following to exist: Windows, DB2, or UNIXODBC.
h4 na locked dot org
пред 23 години
my 2 cents:

function data($res) {
    $obj = new stdClass();
    $data_array = array();
        
    if (!odbc_fetch_into($res, $data_array)) {
        return 0;
    }

    $num_fields = odbc_num_fields($res);

    for ($i = 0;$i < $num_fields; $i++) {
        $name = odbc_field_name($res, $i + 1);
        if (!$name) {
            return 0;
        }
            
        $obj->{$name} = $data_array[$i];
    }
        
    return $obj;
}

works fine for me (PHP 4.3.1)
На оваа страница

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

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

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

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

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