Hello!

On Tue, Mar 06, 2007 at 10:15:27AM -0600, William F Pearson III wrote:
> I'm fairly new to SQLObject

   Welcome!

> The MultipleJoin method is not necessary, but is it
> beneficial?

   It is! See the program and its output:

class Person(SQLObject):
    firstName   = StringCol()
    lastName    = StringCol()
    # Do these three lines matter? Why?
    owner        = MultipleJoin( 'Project', joinColumn='owner_id' )
    contact      = MultipleJoin( 'Project', joinColumn='contact_id' )
    developer  = MultipleJoin( 'Project', joinColumn='developer_id' )

class Project(SQLObject):
    Name                = StringCol(alternateID=True)
    Description = StringCol()
    Owner      = ForeignKey('Person')
    Contact    = ForeignKey('Person')
    Developer = ForeignKey('Person')

Person.createTable()
p1 = Person(firstName="p1", lastName="Person1")
p2 = Person(firstName="p2", lastName="Person2")
p3 = Person(firstName="p3", lastName="Person3")

Project.createTable()
Project(Name="t1", Description="Test 1", Owner=p1, Contact=p2, Developer=p3)
Project(Name="t2", Description="Test 2", Owner=p1, Contact=p3, Developer=p2)

print p1.owner
print p1.contact
print p1.developer

print p2.owner
print p2.contact
print p2.developer

print p3.owner
print p3.contact
print p3.developer

[<Project 1 Name='t1' Description='Test 1' OwnerID=1 ContactID=2 
DeveloperID=3>, <Project 2 Name='t2' Description='Test 2' OwnerID=1 ContactID=3 
DeveloperID=2>]
[]
[]
[]
[<Project 1 Name='t1' Description='Test 1' OwnerID=1 ContactID=2 DeveloperID=3>]
[<Project 2 Name='t2' Description='Test 2' OwnerID=1 ContactID=3 DeveloperID=2>]
[]
[<Project 2 Name='t2' Description='Test 2' OwnerID=1 ContactID=3 DeveloperID=2>]
[<Project 1 Name='t1' Description='Test 1' OwnerID=1 ContactID=2 DeveloperID=3>]

   Understand?

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to