Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.0
#51

[eluser]WanWizard[/eluser]
[quote author="Burton Kent" date="1296772006"]By the way, the search at http://datamapper.wanwizard.eu/ seems to point to the old, temporary site set up at http://datamapper.excitecms.org. Can this be fixed, please?[/quote]
I have updated the site definition for the Google custom search. Don't know how long it will take before this gets live though...
#52

[eluser]WanWizard[/eluser]
[quote author="ipsod" date="1296837630"]Transactions have two Accounts - to and from. Accounts, though, I don't want to have Incomes and Expenses separately, just Transactions, so that I can do $a->transactions->get_iterated(); and have all the transactions ordered by date, but I can't seem to get them set up this way.[/quote]
If you have multiple relationships between two tables, the only way to define them is using advanced relationships. If you use an object of an account to get transactions, you need to specify which relation you want to use (to or from), you can't use both. You can work around that by using
Code:
$transactions->where_related('from', $some_id)->or_where_related('to', $some_id)->get_iterated();
#53

[eluser]Basketcasesoftware[/eluser]
Some questions:
How is the default ordering managed. I see the presence of an example in the template but I can't find any reference to it in the User Guide (the search bar is stuck on the old OverZealous version.) I could swear I've seen something in the Guide mentioning but I can't find it any more. :long:

I'm also not sure how to fully set up relationships for the following:
There is a message system.
The message system is divided into named (and dated) folders.
Each folder may contain many folders.
A folder may be contained by zero or one folder.
A folder may contain many threads.
A thread is contained by only one folder.
A thread contains many messages.
A message is contained by many threads. (This may be a broadcast message).

This is the best I can figure out from the User Guide how to set up the folder relationships:
Code:
// Insert related models that Folder can have just one of.
    var $has_one = array('account');

    // Insert related models that Folder can have more than one of.
    var $has_many = array(
                'parentfolder' => array(
                    'class' => 'folder',
                    'other_field' => 'folder'
                    )
                );

I suspect this isn't complete. The thread and message models I'm sure I can easily handle but the self-referencing folder structure I'm having getting a handle on.

This is a tree structure. DOH! Nested Sets...
#54

[eluser]WanWizard[/eluser]
Are you using the latest version? There should be no reference to OverZealous' website since I've taken over. Download the tip from http://bitbucket.org/wanwizard/datamapper to be sure. Or use the online user guide at http://datamappper.wanwizard.eu.

There is no default ordering, queries return data in whatever order your database will present them if you don't include an ORDER BY clause in your query.

Messaging is complex business, especially if you're buiding for scale. What I've done for a CMS I'm working on is to create the indices as nested trees (in my case forums, threads and PM's), and made sure the records are fixed length. The message text itself is in a separate table, linked to by the id, together with specific message attributes like author, timestamps, etc. This will also allow the message to appear in multiple places.

You can use Datamapper's nested sets extension, which works pretty ok for standard nested set constructions. It's documented in the user guide.
#55

[eluser]Basketcasesoftware[/eluser]
[quote author="WanWizard" date="1297054544"]Are you using the latest version? There should be no reference to OverZealous' website since I've taken over. Download the tip from http://bitbucket.org/wanwizard/datamapper to be sure. Or use the online user guide at http://datamappper.wanwizard.eu.

There is no default ordering, queries return data in whatever order your database will present them if you don't include an ORDER BY clause in your query.

Messaging is complex business, especially if you're buiding for scale. What I've done for a CMS I'm working on is to create the indices as nested trees (in my case forums, threads and PM's), and made sure the records are fixed length. The message text itself is in a separate table, linked to by the id, together with specific message attributes like author, timestamps, etc. This will also allow the message to appear in multiple places.

You can use Datamapper's nested sets extension, which works pretty ok for standard nested set constructions. It's documented in the user guide.[/quote]

I'm using the current version. Or so I thought. No biggie.
The messenging I'm working on is the users' private mail boxes (PMs). I'm trying to allow them to organize their received messages in folders and sub-folders. I realized I needed nested trees towards the end of my last post. What records are you keeping as a fixed length?
I am keeping the messaging table separate with date, author, subject, etc. I'm keeping the subject length to 120 characters (I borrowed that figure from your examples. Seemed a reasonable suggestion).

So far I've broken things down into three tables: Folders, Threads, and Messages.
folder: has_one 'account' (I suspect I need more here).
thread: has_many 'folder' 'message'
message: has_one 'thread' 'creator'
has_many 'contributor'
#56

[eluser]eXpi[/eluser]
Hi I'm having a problem with Datamapper. I hope this is the right place to post this.
First I have to admit that I am still using Datamapper 1.7.1 but I didn't notice any bug fix related to this in the changes.

I'm trying to generate the following query:

Code:
UPDATE optiongroups_products SET defaultoption = 0 WHERE optiongroup_id = $ogrid

by writing this:

Code:
$og = new Optiongroup();
$og->get_by_id($ogrid);

$og->set_join_field('product', 'defaultoption', 0)

but instead of the above query, the following query is created:

Code:
UPDATE optiongroups_products SET defaultoption = 0 WHERE optiongroup_id = 2 AND product_id IS NULL

which does nothing since none of the product_ids can ever be null.

Am I doing something wrong here, or is this a datamapper bug?
#57

[eluser]Robert Liljedahl[/eluser]
I'm stuck on howto make a query.
I got groups, permissions and modules. I'm working on the update-function in the groups-controller.
I want to list all the modules and show if the group do in fact have access to the module in question.

It's easy for me to get all modules. It's also easy for me to get all permissions for a certain group.
The question is how I combine these two into on query for DataMapper.

This is how I'd do it with a 'normal' query:

Code:
SELECT modules.*, permissions.id AS 'permission_id'
  FROM modules
    LEFT OUTER JOIN permissions
      ON (permissions.module_id = modules.id AND permissions.group_id = 4)
  GROUP BY modules.id
#58

[eluser]Basketcasesoftware[/eluser]
Researching now unless wanwizard beats me to the answer ,@Robert Liljedahl.
I'm also looking into your issue, @eXpi, but, again, wanwizard might be of better help.
#59

[eluser]Spir[/eluser]
I have a cache related question: what's going on if I have a multi domain app (several domain working with one application folder)? Should I have a cache folder per domain?
I dynamically change model's table name for each domain.
#60

[eluser]Basketcasesoftware[/eluser]
I would. At least when you look at your cache for diagnostics you know what domain each record belongs to.




Theme © iAndrew 2016 - Forum software by © MyBB