CodeIgniter Forums
DataMapper ORM v1.8.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper ORM v1.8.0 (/showthread.php?tid=37531)



DataMapper ORM v1.8.0 - El Forum - 04-25-2011

[eluser]Maucomix[/eluser]
[quote author="WanWizard" date="1303734959"]Should be fixed again.

My server was down, and I'm out of the country at the moment. Took some time to find someone to fix the issue...[/quote]

Ty =]!


DataMapper ORM v1.8.0 - El Forum - 04-25-2011

[eluser]Spir[/eluser]
I think there is an issue with loading model validation's label. Maybe someone already pointed this anyway: in constructor around line 668 there is this loop:

Code:
// Finally, localize the labels here (because they shouldn't be cached
            // This also sets any missing labels.
            $validation =& DataMapper::$common[$common_key]['validation'];
            foreach($validation as $field => &$val)
            {
                // Localize label if necessary
                $val['label'] = $this->localize_label($field,
                        isset($val['label']) ?
                            $val['label'] :
                            FALSE);
            }

I didn't set my language file and I'm using validation array with label. But in this validation array I don't have for example the :
user_created
user_updated
fields which is logical.
Also in my logs I keep seeing this :
Quote:Could not find the language line "user_created"

(since with CI 2.0.2 comes some bug fix with language core class which write logs when key was not found).
Anyway logs are getting heavy since it's an error log and since everytime a page is loaded it will write this.
So I think that loop I was talking previously would be better a bit upper in the code before loading the general model settings. I didn't digg much more sorry.


DataMapper ORM v1.8.0 - El Forum - 04-25-2011

[eluser]Spir[/eluser]
I have made a new issue.
https://bitbucket.org/wanwizard/datamapper/issue/47/log-error-could-not-find-the-language-line

Sorry for not being crystal clear Sad
My english sux


DataMapper ORM v1.8.0 - El Forum - 04-26-2011

[eluser]WanWizard[/eluser]
And they call that a bug fix?

I understand the issue, I'll look at it for the next release.


DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]introvert[/eluser]
Hi,

I'm trying to implement nestedsets in my Datamapper model.

I followed the instructions on DM wanwizard site but I get the following errors:

Code:
Message: Undefined property: Test::$db

Filename: libraries/datamapper.php

Line Number: 1042

Message: register_shutdown_function() [function.register-shutdown-function]: Invalid shutdown callback 'Array' passed

Filename: libraries/datamapper.php

Line Number: 1042

Fatal error: Call to undefined method stdClass::_reset_select() in /Applications/MAMP/htdocs/kundi/application/libraries/datamapper.php on line 1047

I added the 'nestedsets' extension in the datamapper config, added the columns root_id, left_id, right_id and defined $nestedsets in the model:

Code:
var $nestedsets = array(
    'name' => 'name',
    'follow' => FALSE
  );

When I construct the model, I get the error message above.

Anyone has idea what is going on?

Thanks for help


DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]introvert[/eluser]
Ok, I managed to solve the previous problem.

One more thing:

How do you create tree with multiple root nodes?
Documentation is a little bit unclear regarding that..

Obviously I cannot use new_next_sibling function on root nodes..

Could you provide a simple example? Do I have to turn on symlinking for that?

Thanks for help!


DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]rherriman[/eluser]
As far as I can tell, there is an error in the documentation. There is no select_tree method. The proper way for creating a new root seems to be exactly as shown in the Usage section of the documentation, like this:

Code:
$tree = new Tree();
$tree->select_root(99); // make sure root_id 99 doesn't exist yet!
$tree->new_root();

Obviously it would be better if new_root could just be called, and the root_id auto-incremented, but according to the documentation "currently, this doesn't happen automatically." So I guess you need to find the next root_id yourself.


DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]introvert[/eluser]
Thats exactly what I do.

When I call new_root() function DM will create new root node with left 1 and right 2 instead of 3 and 4 in case the previous root exists.

How really can you create multi root nodes with this structure:

Code:
name       left     right
root_1     1     2
root_2     3    4
root_3    5    6

Is this even possible?


DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]danijelb[/eluser]
Hello Smile

I have an unusual relationship and I don't know how to connect those two tables.

First table is Contents, second table is Pages...
Every row in Contents has in_table_id (page_id) and every of the content type tables (Pages, Articles, Images) have an id...

How should I connect those two?

I would normally do this:
Code:
SELECT p.id, p.title, p.content, p.language_id, c.id as content_id, c.slug, c.uid, c.parent_id
FROM pages p
LEFT JOIN contents AS c
ON p.id = c.in_table_id



DataMapper ORM v1.8.0 - El Forum - 04-27-2011

[eluser]introvert[/eluser]
[quote author="danijelb" date="1303931608"]Hello Smile

I have an unusual relationship and I don't know how to connect those two tables.

First table is Contents, second table is Pages...
Every row in Contents has in_table_id (page_id) and every of the content type tables (Pages, Articles, Images) have an id...

How should I connect those two?

I would normally do this:
Code:
SELECT p.id, p.title, p.content, p.language_id, c.id as content_id, c.slug, c.uid, c.parent_id
FROM pages p
LEFT JOIN contents AS c
ON p.id = c.in_table_id
[/quote]

Oh my god, rtfm - model relations.