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

[eluser]WanWizard[/eluser]
@mrtopther,

So, what is the result (in the profiler) if you you run bEz's code on your prod server? I'm running 5.3.6. in my development environment, and I can't reproduce it either.

[eluser]mrtopher[/eluser]
Yeah, I just literally right now figured out what was going on (was making another call before the one in question without passing in the relationship name so I was looking in the wrong place this whole time for the problem). Just dealing with a loose nut behind the keyboard is all.

All is good, let's just pretend this didn't happen Wink

Thanks again for the help!!

[eluser]Spir[/eluser]
Here is my category example I was talking previously :
Model:
Code:
class Category extends DataMapper {
    public $has_one = array(
        'parent_category' => array(
            'class' => 'category',
            'other_field' => 'category',
        ),
    );
    public $has_many = array(
        'category' => array(
            'other_field' => 'parent_category',
        )
    );
    public $table = 'categories';
}

With SQL code :
Code:
CREATE  TABLE IF NOT EXISTS `categories` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `parent_category_id` INT NULL ,
  `created` DATETIME NULL ,
  `updated` DATETIME NULL ,
  PRIMARY KEY (`id`) );

When saving I have to do that way :
Code:
$parent_category = new Category($some_id);
$category = new Category();
$category->save(Array('parent_category'=>$parent_category));

If I want to set a child cat I do :
Code:
$category = new Category($some_id);
$child_category = new Category();
$category->save($child_category); // implict $category->save(Array('category'=>$child_category));

Thanks for your help WanWizard. It works great. Hope it helps someone who build tree relations.

[eluser]theprodigy[/eluser]
I'm not sure if this has been discussed or not, and if not, I'm surprised, but I can't seem to find any post discussing the issue.

I am currently using:
Quote:CI 2.0.2
DMZ 1.8.0
MX 5.4

I created a module, created controllers dir, models dir, and views dir.
In my controller, I instantiate a new model, and run the get() function, to get all records from the database then assign it to $this->data.

When I go to my view via the browser, I get a PHP Fatal Error that it cannot find my model file.

If this has already been discussed, please direct me to the proper thread. If not, can someone please help me.

Thanks

[eluser]WanWizard[/eluser]
You load the model in your view?

Where is the controller? The model? The view? In app space, or in an MX module. And if in an MX module, is the module loaded (this will add the module's model directory to the loaders search path).

[eluser]theprodigy[/eluser]
Quote:In my controller, I instantiate a new model, and run the get() function, to get all records from the database then assign it to $this->data.
Quote:You load the model in your view?
Not sure where you got that from, but no, I am loading the model in my controller.

Quote:Where is the controller? The model? The view? In app space, or in an MX module. And if in an MX module, is the module loaded (this will add the module’s model directory to the loaders search path).
My folder structure is:
Quote:--application
--|--controllers
--|--models
--|--modules
--|--|--movies
--|--|--|--controllers
--|--|--|--|--movies.php
--|--|--|--models
--|--|--|--|--movie.php
--|--|--|--views
--|--|--|--|--movies
--|--|--|--|--|--index.php
--|--views

[eluser]WanWizard[/eluser]
You wrote
Quote:When I go to my view via the browser, I get a PHP Fatal Error that it cannot find my model file.
Why would it try to load something if there's no code to do that?

You also wrote
Quote:In my controller, I instantiate a new model, and run the get() function, to get all records from the database then assign it to $this->data.
which lead me to assume that the model works.


Do you have error reporting and display enabled? Any errors in CI's log or your webservers log?

I don't know how much of the recent Reactor code found it's way into CI 2.0.2, but Datamapper is broken in Reactor when it comes to modular solutions, due to the fact that the Reactor team has decided to make a lot of the loader class properties private. This makes core extension drop-in's a disaster, since you now also have to extend core classes to get things to work. Major foobar imho...

[eluser]theprodigy[/eluser]
Quote:You also wrote

Quote: In my controller, I instantiate a new model, and run the get() function, to get all records from the database then assign it to $this->data.

which lead me to assume that the model works.
Sorry for the confusion. I was basically just trying to explain the code that I had in place.

Quote:Do you have error reporting and display enabled? Any errors in CI’s log or your webservers log?

app/logs is empty, and apache logs are showing 200

Quote:I don’t know how much of the recent Reactor code found it’s way into CI 2.0.2, but Datamapper is broken in Reactor when it comes to modular solutions,...

so, basically, I'll have to take my models out of the modules and keep them in app/models?

[eluser]WanWizard[/eluser]
Since you don't have any PHP errors, I have to assume that these changes haven't found their way to the official CI version yet.

Datamapper uses CI 2's package mechanism to locate models in modules. When you run a controller from a module, MX adds the module's model path to the package paths, allowing the Datamapper autoloader to find it. If you call the model from outside the module, you have to call _add_module_paths() in MX' loader class yourself.

If you want to debug Datamappers autoloader, add a var_dump() to the foreach in the autoload() method of the Datamapper library. I don't use MX, so I can't help you with that...

[eluser]theprodigy[/eluser]
ok, I feel like a complete and utter newb at this point.

I figured out what the problem was.

I went into datamappers autoload and put in the var_dump like you suggested. I refreshed the page and didn't get anything. So I thought about it for a minute and did a facepalm. I completely forgot to autoload the datamapper library.

Once I did that, I refreshed the page, and everything seems to be working fine.

**pushes button to sound the NEWB ALARM before tucking his head down and walking out**




Theme © iAndrew 2016 - Forum software by © MyBB