Re: Casting objects.
| From: | Shawn McKenzie | Date: | Mon, 18 Jan 2010 15:49:06 +0000 |
| Subject: | Re: Casting objects. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301197@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
> Hello.
>
> I've got an object via odbc_fetch_object (which is of stdClass).
>
> I have an class structuresRemovalReason.
>
> I want to cast the response of odbc_fetch_object to structuresRemovalReason.
>
> The only way I can see of doing this is to not use odbc_fetch_object,
> but odbc_fetch_assoc and then iterate the array and populate a new
> structuresRemovalReason.
>
> Or an I missing a trick. I'm pretty sure I am.
>
> Regards,
>
> Richard Quadling.
>
Something like this in your class or another class may work (not
tested). You might even fetch an array and send it to this method. I
think either should work:
class structuresRemovalReason {
static public function cast(structuresRemovalReason $object) {
return $object;
}
}
$row = structuresRemovalReason::cast(odbc_fetch_object($result));
--
Thanks!
-Shawn
http://www.spidean.com