Hello,
on 02/21/2008 11:32 AM Miguel Oliveira said the following:
> I've created 2 object factory functions of type createobject, one for
> each class of user and profile. But it returns that a missing
> argument is missing, which is the profile_id and user_id.
Yes, you need to make those variables optional to be allowed to save the
object without setting them to a reference object.
Since the classes reference each other, you need to make at least one of
the variables optional.
> As it sustends 'applications should not access reference variables
> directly to manipulate the respective objects. Instead you should
> declare and use functions of type setreference and getreference to
> assign or retrieve the related objects by storing or de-referencing
> the respective OID. '
>
> And:
>
> 'Applications should not access reference variables directly to
> manipulate the respective objects. Instead you should declare and use
> functions of type setreference and getreference to assign or retrieve
> the related objects by storing or de-referencing the respective OID.
> See the section ahead about defining data objects functions to learn
> how to declare and use this type of functions.'
>
> How can i create object user and profile and set references in a form
> of 1-to-1 relationship? Like this?
>
> <function>
> <name>setprofileid</name>
> <type>setreference</type>
> <parameters>
> <variable>profile_id</variable>
> <reference>
> <argument>profile</argument>
> </reference>
> </parameters>
> </function>
>
> <function>
> <name>setuserid</name>
> <type>setreference</type>
> <parameters>
> <variable>user_id</variable>
> <reference>
> <argument>user</argument>
> </reference>
> </parameters>
> </function>
Yes, that is it. You just need to add the functions the respective classes.
> Also, should i call these functions before persist the database?
Of course.
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/