Hi,

If your 'UserAssociationWithJobs' is an intersection table (it links jobs to users and vice versa) you can use findManyToManyRowswet, and some other methods. See the manual for this: http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.many-to-many . It works just like a one to one or one to many relation, except you need that intersection table.

Adding, editing and deleting can be done just like a 'regular' row. You can 'connect' them with $_referenceMap and $_dependentTables. Like Bill Karwin remarked you should probably try to specify contraints on your database that ensure that if you delete a user it's association with jobs will be deleted as well. But you could do this in your php files if your database doesn't support it.

MF

José de Menezes Soares Neto wrote:
Nice, but I have one more question:

If you have three tables, Users, UserAssociationWithJobs, Jobs... there is a way to simple connect this tables for add, edit and delete actions?

Cause a User could have one or more jobs, and we have a table with the possible jobs... and if you would like to add, edit and delete using SQL and some php you could, but with ZF there is easier or similar ways??

best regards,

José de Menezes

2007/5/4, Bill Karwin <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

    Actually, all you need for the table relationships to work is the
    $_referenceMap in the dependent table's class definition.

    The $_dependentTables variable is optional.  This is needed only
    if you want to perform cascading UPDATE and DELETE operations in
    PHP code.  This is not needed if you use constraints in your
    database to perform referential integrity.  I recommend utilizing
    database constraints, it's safer and gives better performance.

    Regards,
    Bill Karwin

    > -----Original Message-----
    > From: Maurice Fonk [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>]
    > Sent: Friday, May 04, 2007 5:23 PM
    > To: José de Menezes Soares Neto
    > Cc: [email protected] <mailto:[email protected]>
    > Subject: Re: [fw-general] Working with two or more tables
    >
    > Hi again!
    >
    > Have a look at
    > http://framework.zend.com/manual/en/zend.db.table.relationship
    > s.html . I know it seems complicated at first, but you'll
    > learn to appreciate it quickly. For your example, I could
    > imagine that the table userinfo depends on the table user, so
    > you'd put:
    >
    > protected $_dependentTables = array('Userinfo');
    >
    > in the class definition for User. Then you could use the
    > magic function:
    >
    > $user->findUserinfo()
    >
    > on a User Row.
    >
    > MF
    >
    > José de Menezes Soares Neto wrote:
    > > Hi again my friends!
    > >
    > > Now, I need to work with two or more tables, each table has some
    > > information I need.
    > > For example, table USERS has the users, but I need too
    > table USERINFO,
    > > which have the user information...
    > >
    > > I created a class that extends Zend_Db_Table_Abstract:
    > >
    > > class Users extends Zend_Db_Table_Abstract {
    > >     protected $_name = 'users';
    > > }
    > >
    > > But, I would like to manage more tables, and get flexibility to
    > > combine then... these kind of things...
    > >
    > > Best regards,
    > >
    > > José
    >
    >
    > --
    > Maurice Fonk
    >
    > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    > http://naneau.nl/
    >
    > Scio me nihil scire
    >
    >




--
Maurice Fonk

[EMAIL PROTECTED]
http://naneau.nl/

Scio me nihil scire

Reply via email to