Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
ORM many to many confusion
corbosman
February 2013
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?
corbosman
February 2013
Never mind, I solved the issue. I had to swap from/to in 1 of the models.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
corbosman
February 2013