why mot just
<?php
         $foo = new Foo( $db->fetchRow(DB_FETCHMODE_ASSOC) );
?>

If you have to leave this part of the project for any length of time, 
coming back to the above would be much less confusing. ( i think so anyway :)

morgan

At 03:12 PM 4/13/2001 -0500, you wrote:
>Can you cast an array to an object of your choosing? If so, will the keys of
>the array match up with the attributes of your object?
>
>Say I have a class like this:
>
>class Foo {
>     var $foo;
>     var $bar;
>
>     function Foo($foo = '', $bar = '') {
>     ...
>     }
>     ...
>}
>
>Then I have an array like:
>
>     $array['foo'] = "Hello";
>     $array['bar'] = "world";
>
>If I do this:
>
>$foo = new Foo();
>$foo = (object)$array;
>
>I've seen something similar done, but how do you keep $foo from forgetting
>which class it belongs to? The second assignment is independent of the first
>one, so $foo should become a plain object and forget that it's a "Foo"
>object.
>
>Any ideas?
>
>By the way, I was thinking this would be a really nifty way to fetch rows
>from the database into a pre-written class instead of doing it all manually.
>You'd have all the object properties automatically set by:
>
>$my_object = (object)$db->fetchRow(DB_FETCHMODE_ASSOC);
>
>I'm just worried about the object losing its membership in its original
>class.
>
>Dean.
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

===
Morgan Curley
Partner, e4media

212 674 7698
[EMAIL PROTECTED]
http://www.e4media.com
__________________________________________________



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to