Search the web
Sign In
New User? Sign Up
metal-dev · MetaL Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
setreference for foreign keys in 1-to-1 relationshipship   Message List  
Reply | Forward Message #525 of 553 |
Re: [metal-dev] setreference for foreign keys in 1-to-1 relationshipship

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/



Thu Feb 21, 2008 8:06 pm

mallemos
Offline Offline
Send Email Send Email

Forward
Message #525 of 553 |
Expand Messages Author Sort by Date

Hello, I was wondering how can i solve the creation of 2 objects with an 1- to-1 relationship. Using this example class: <class> <name>user</name> <variable> ...
Miguel Oliveira
miguel@...
Send Email
Feb 21, 2008
2:31 pm

Hello, ... 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...
Manuel Lemos
mallemos
Offline Send Email
Feb 21, 2008
8:06 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help