PDOStatement::fetchObject
Retrieves the next row as an object.
Syntax
mixed PDOStatement::fetchObject([ $class_name[,$ctor_args ]] )
Parameters
$class_name: An optional string specifying the name of the class to create. The default is stdClass.
$ctor_args: An optional array with arguments to a custom class constructor.
Return Value
On success, returns an object with an instance of the class. Properties map to columns. Returns false on failure.
Remarks
Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.
Example
<?php
$server = "(local)";
$database = "AdventureWorks";
$conn = new PDO( "sqlsrv:server=$server ; Database = $database", "", "");
$stmt = $conn->query( "select * from Person.ContactType where ContactTypeID < 5 " );
$result = $stmt->fetchObject();
print $result->Name;
?>
See Also
Tilbakemeldinger
https://aka.ms/ContentUserFeedback.
Kommer snart: Gjennom 2024 faser vi ut GitHub Issues som tilbakemeldingsmekanisme for innhold, og erstatter det med et nytt system for tilbakemeldinger. Hvis du vil ha mer informasjon, kan du se:Send inn og vis tilbakemelding for