-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi.
- --On 21.05.2002 15:19:11 +0400 Victor Kapustin wrote:
>> A PHP-like approach using
>> something like
>>
>> $variables = get_object_vars($object);
>> foreach($variables as $var => $data)
>> $this->$var = $data;
>>
>> does not always work cleanly, you can get errors due to missing
>> variables which are very hard to trace, believe me...
>
> (1)
> Any mgd_..._list_... function delivers "truncated" object which lacks
> MOST of the members the normal corresponding object obtained with
> mgd_get_... has.
> It has only __table__, id and sitegroup as its members (in common
> with a normal object ;-)
This is done for performance reasons. The best way to use the
fetchables is to do something like
$result = mgd_list_xxx(blah);
if ($result)
while ($object = $result->fetch())
{
$object = mgd_get_xxx($result->id);
// do something with $object
}
I built a wrapper functions called mgd_fetch_to_array($fetchable) [1]
for this to help me with my customized sorting procedures [2]. If
anybody has sorting problems, take a look at those functions, they
should do almost everything what someone might imagine.
[1]
http://www.nathan-syntronics.de/midgard/snippets/sorting/mgd_fetch_to_a
rray.html
[2] http://www.nathan-syntronics.de/midgard/snippets/sorting/
> (2)
> Any mgd_..._list_... function delivers an object with TWO EXTRA
> members: N and __res__.
... where N is the number of objects that have been returned and
__res__ is some internal variable identifying the result set.
> (5)
> The lists of methods for both kinds of Midgard objects (list and get)
> coincide. I wonder what does fetch() fetch for the object obtained
> with "get" - sorry, I didn't try it - probably, it'll return false.
It should not be possible to call fetch() on a object obtained by
mgd_get_xxx(). I too haven't tried this, but if it is defined as a
method (it is, if I remember the source right), it must return false
upon call. Similarily, N would be 1 and __res__ either undefined or
NULL.
> (6)
> Any object has a single method, which isn't described in the Manual
> (among other methods). Its name starts with "midgard", but the tail
> of the name can have spaces and quotes in it:
>
> midgardtopic
> midgardarticle
> midgardgroup
>
> But:
>
> midgard "event"
> midgard "event_member"
> midgard "person"
>
> I wonder: can one make any use of this method(s)?
Should not be possible, since >midgard "person"< is not a valid
function name in PHP. The upper ones (midgardtopic...) do look like
they are constructors. Not sure though. If they are, the latter ones
with the spaces and quotes definitly look like a bug.
> A synopsis:
>
> Torben is right. The OOP life with Midgard is somewhat more tough
> than one could expect.
It is, thats why we here at Link-M started with PHP Midgard Base Class
[3] development for use with OOP, these functions should wrap
everything neccessary for PHP usage. Be cautionous though, the classes
are not completly tested yet, and we have roumours of several bugs
here, which are all unconfirmed yet.
[3] http://www.nathan-syntronics.de/midgard/oop/
> Praemonitus -- praemunitus.
Can anybody translate this to someone without Latin knowledge?
> Thanks, Torben.
You're welcome!
Live long and prosper!
Torben Nehmer
- --
Torben Nehmer, Munich, Germany
http://www.nathan-syntronics.de, mailto:[EMAIL PROTECTED]
PGP Public Key ID on wwwkeys.(de.)pgp.net: 0x7E9DE456
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE86jcdJPh4Kn6d5FYRAjnvAKCrFFqKmia2xMIPj3my8ojpPYKarACgzZYP
cPtaOGJsBQfrVSs8rcniBAw=
=kxcs
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]