Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM many to many confusion
  • Hi all, im using the ORM to define a many to many relationship. The two models can be seen here:  http://pastebin.com/Fnn60YaC

    My tables:

    mysql> select * from users;
    +----+----------+----------------------------------------------+-------+----------------+------------+------------+----------------+------------+------------+
    |
    id | username | password                                     | group |
    email          | last_login | login_hash | profile_fields | created_at |
    updated_at |
    +----+----------+----------------------------------------------+-------+----------------+------------+------------+----------------+------------+------------+

    1 | cor      | cX1iYPpD0MDcuCK9jVA77X6RM8wy6yLzMJffY/76rng= |     1 |
    cor@in.ter.net | 0          |            | a:0:{}         | 1359725581
    |          0 |
    +----+----------+----------------------------------------------+-------+----------------+------------+------------+----------------+------------+------------+
    1 row in set (0.00 sec)

    mysql> select * from domains;
    +----+---------------+------------+------------+
    | id | domain        | created_at | updated_at |
    +----+---------------+------------+------------+
    |  3 | bofh.nl       | 1359740535 | 1359740583 |
    |  4 | blognation.nl | 1359741358 | 1359741358 |
    +----+---------------+------------+------------+
    2 rows in set (0.00 sec)

    mysql> select * from domains_users;
    +-----------+---------+
    | domain_id | user_id |
    +-----------+---------+
    |         1 |       3 |
    |         1 |       4 |
    +-----------+---------+
    2 rows in set (0.00 sec)

    I created these like:

    $d = new Model_Domain;
    $d->domain = 'blognation.nl';
    $d->users[] = Model_User::find(1);
    $d->save();

    My question is, arent the column names of the in between table switched around? If so, how did that happen? Do I have a mistake in my models?
  • Never mind, I solved the issue. I had to swap from/to in 1 of the models.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion