Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.2

[eluser]WanWizard[/eluser]
This is in the manual.

Relationship tables or join tables are by default named by the two table names that make the relation, in alphabetical order. So "groups_users" in this case.

If you want or need to deviate from that, you can define an advanced relationship between the tables, in which you can define the name of the relationship table.

[eluser]AlexMason[/eluser]
Yea, well my brain melted after reading those docs. It's thorough but very advanced. I have never used an ORM but I liked the idea so I dove right into it for my next project. And I can honestly say I love its power and abstraction. It is absolutely beautiful. Great work, and awesome support from you bud.

[eluser]WanWizard[/eluser]
It's kudos like this that keeps me going! Thanks!

[eluser]AlexMason[/eluser]
@WanWizard
I have a datamapper model setup. But I had to rename it because it conflicted with one of my controllers. I user var tables to set the mysql table approiatly but for the {model}_id in the database it defaults to the model name not the var table name is there anyway I can change this. (Visual idea below)

----

file.php - controller
userfile.php - model extends datamapper
-- var table = "files"

mysql requests to get userfile_id in my relationship table instead of file_id

[eluser]WanWizard[/eluser]
That is because the relations are based on relation name, and not on table name. And by default relation names are equal to the classname.

You'll have to define an advanced relationship for this. Maybe this will already do:
Code:
$has_many('file' => array('class' => 'userfile'));

[eluser]AlexMason[/eluser]
Not sure, Ill just work around it. It's not a critcal need. I'm just polishing touches on my file hosting site.

[eluser]ckm5[/eluser]
[quote author="WanWizard" date="1335606207"]@ckm5,

If you get that error then $this->db doesn't point to Datamapper but to the original CI class.

As line 3550 in my version doesn't contain a dm_call_method() call, I suggest you upgrade to the latest version first (both library, extensions and the third_party/datamapper folder) from bitbucket.[/quote]

OK, but I'd like to note that I re-installed the latest package twice to make sure it wasn't me.

I'll pull a new download from BitBucket to see if that fixes it.

Thx.

Chris.

[eluser]ckm5[/eluser]
[quote author="WanWizard" date="1335606207"]@ckm5,

If you get that error then $this->db doesn't point to Datamapper but to the original CI class.

As line 3550 in my version doesn't contain a dm_call_method() call, I suggest you upgrade to the latest version first (both library, extensions and the third_party/datamapper folder) from bitbucket.[/quote]

That looks like it did it. The code I quoted seems to run fine...

Thx.

Chris.

[eluser]tarciozemel[/eluser]
Man, those forum update alerts in email sucks! The last message with updates which I received in this topic was about a month ago (page 30)... :down:

[eluser]tarciozemel[/eluser]
Join field value in a many to many relationship save

Hi, folks!

I have a company and email_type models. In the company create form, it's possible to add how many emails the user wants. The data is stored in DB in a table with the fields: "id", "company_id", "email_type_id" and "email" (the value, itself).

As showed in this image, the type of email is passed as the value of combobox and, the "email" itself, it's typed (duh).

So, my question is: how, in the company save() method, can I save that many emails relationships in one shot WITH their respective join values?




Theme © iAndrew 2016 - Forum software by © MyBB