Re: Casting objects.

From: Date: Mon, 18 Jan 2010 16:03:33 +0000
Subject: Re: Casting objects.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-301199@lists.php.net to get a copy of this message
Shawn McKenzie wrote: > 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)); > Never mind, that was stupid. I saw that somewhere before, but obviously it doesn't work. -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#301199) next »