<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >sybase_fetch_object</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Sybase Functions" HREF="ref.sybase.html"><LINK REL="PREVIOUS" TITLE="sybase_fetch_field" HREF="function.sybase-fetch-field.html"><LINK REL="NEXT" TITLE="sybase_fetch_row" HREF="function.sybase-fetch-row.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sybase-fetch-field.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.sybase-fetch-row.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.sybase-fetch-object" ></A >sybase_fetch_object</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN232866" ></A ><P > (PHP 3, PHP 4, PHP 5)</P >sybase_fetch_object -- Fetch a row as an object</DIV ><DIV CLASS="refsect1" ><A NAME="AEN232869" ></A ><H2 >Description</H2 >object <B CLASS="methodname" >sybase_fetch_object</B > ( resource result [, mixed object] )<BR ></BR ><P > Returns an object with properties that correspond to the fetched row, or <TT CLASS="constant" ><B >FALSE</B ></TT > if there are no more rows. </P ><P > <B CLASS="function" >sybase_fetch_object()</B > is similar to <A HREF="function.sybase-fetch-assoc.html" ><B CLASS="function" >sybase_fetch_assoc()</B ></A >, with one difference - an object is returned, instead of an array. </P ><P > Use the second <CODE CLASS="parameter" >object</CODE > to specify the type of object you want to return. If this parameter is omitted, the object will be of type stdClass. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > As of PHP 4.3.0, this function will no longer return numeric object members. </P ><P > Old behaviour: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >object(stdclass)(3) { [0]=> string(3) "foo" ["foo"]=> string(3) "foo" [1]=> string(3) "bar" ["bar"]=> string(3) "bar" }</PRE ></TD ></TR ></TABLE > New behaviour: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >object(stdclass)(3) { ["foo"]=> string(3) "foo" ["bar"]=> string(3) "bar" }</PRE ></TD ></TR ></TABLE > </P ></BLOCKQUOTE ></DIV ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN232893" ></A ><P ><B >例 1. <B CLASS="function" >sybase_fetch_object()</B > return as Foo</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /> </font><font color="#007700">class </font><font color="#0000BB">Foo </font><font color="#007700">{<br /> var </font><font color="#0000BB">$foo</font><font color="#007700">, </font><font color="#0000BB">$bar</font><font color="#007700">, </font><font color="#0000BB">$baz</font><font color="#007700">;<br /> }<br /> <br /> </font><font color="#FF8000">// {...]<br /> </font><font color="#0000BB">$qrh</font><font color="#007700">= </font><font color="#0000BB">sybase_query</font><font color="#007700">(</font><font color="#DD0000">'SELECT foo, bar, baz FROM example'</font><font color="#007700">);<br /> </font><font color="#0000BB">$foo</font><font color="#007700">= </font><font color="#0000BB">sybase_fetch_object</font><font color="#007700">(</font><font color="#0000BB">$qrh</font><font color="#007700">, </font><font color="#DD0000">'Foo'</font><font color="#007700">);<br /> </font><font color="#0000BB">$bar</font><font color="#007700">= </font><font color="#0000BB">sybase_fetch_object</font><font color="#007700">(</font><font color="#0000BB">$qrh</font><font color="#007700">, new </font><font color="#0000BB">Foo</font><font color="#007700">());<br /> </font><font color="#FF8000">// {...]<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > Speed-wise, the function is identical to <A HREF="function.sybase-fetch-array.html" ><B CLASS="function" >sybase_fetch_array()</B ></A >, and almost as quick as <A HREF="function.sybase-fetch-row.html" ><B CLASS="function" >sybase_fetch_row()</B ></A > (the difference is insignificant). </P ><P > See also <A HREF="function.sybase-fetch-array.html" ><B CLASS="function" >sybase_fetch_array()</B ></A > and <A HREF="function.sybase-fetch-row.html" ><B CLASS="function" >sybase_fetch_row()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.sybase-fetch-field.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sybase-fetch-row.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >sybase_fetch_field</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.sybase.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sybase_fetch_row</TD ></TR ></TABLE ></DIV ></BODY ></HTML >