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

[eluser]Maglok[/eluser]
Hey all,

Today I noticed something odd in my datamapper installation for a application.

Code:
public $auto_populate_has_many = TRUE;

This does not seem to actually set the populate_has_many config to true. If I change it in the datamapper.php config file it does do this. I have printed entire datamapper objects to see and it is simply not set even though I use it on the exact same location in other applications.

The only thing I can think of is a simple thought process problem on my side, a scope thing or the fact this app is running on a IIS server.

Regardless it is all rather time sensitive and if anyone has had this happen and can throw a quick 'ah that is probably because' at me, I would be indebted.

[eluser]WanWizard[/eluser]
That is strange.

In the constructor all config properties are created from config, but only if they don't exist yet:
Code:
foreach (DataMapper::$config as $config_key => &$config_value)
{
if ( ! property_exists($this, $config_key))
{
  $this->{$config_key} = $config_value;
}
}

So a property explicitly defined in a model should remain untouched.

[eluser]Maglok[/eluser]
That is exactly why I am wondering what is up. I actually did take a look in the code and the fact that the overall config does make it auto_populate and a local (in a datamapper model) config does not makes me think it must be the definition. I have done this a dozen times though and my other models look exactly the same and do work.

I did do a quick check in the constructor of the account model like so:

Code:
echo $this->auto_populate_has_many;

Which did give me proper response that the value is set at the moment in the code execution. Same thing for the post_model_init. I also came back to the variable later on by writing a small custom function that gives me the value of auto_populate_has_many in the view. So the model is quite aware of the value.

I found the following:

Code:
// Load stored config settings by reference
  foreach (DataMapper::$config as $config_key => &$config_value)
  {
   // Only if they're not already set
   if (property_exists($this, $config_key))
   {
    $this->{$config_key} =& $config_value;
   }
  }

This does not look like the code you quoted, so I might be at the wrong place (though I did search through the datamapper.php library for your quote). The version I am running here is 1.8.2. Obviously I went to check on the version I use in my sandbox environment. That is 1.8.1-dev (cause it can be unstable I am fine with that).

Did I grab some sort of bad version running 1.8.2?

[eluser]Spir[/eluser]
Anyone want to help trying to port this lib to Laravel 4?

[eluser]extractortotem[/eluser]
Hi,

I'm an absolute beginner in CI and DM ORM, and I had a quite serious struggle and frustration to get the 'nestedsets' extension working. May I post my notices/questions here, or should I open a new topic for it?

Thanks,
Best Regards,
ET

[eluser]Unknown[/eluser]
I'm looking into creating an app with a LOT of tables and objects and would love to use DataMapper, but I'm having issues getting the most basic code working. I've installed the DataMapper-ORM spark... version 1.8.2 and I've loaded the spark correctly. I've included the bit that's supposed to load the DataMapper bootstrap file in index.php, I've got my db creds setup. The welcome page works fine, no errors, but as soon as I add the following line inside my welcome.php controller to test:

Code:
$u = new User();

Stuff blows up. I'm getting a 500 error. I have setup my User model correctly, but for some reason, whenever I try to create a new object, it throws a 500 error at me. Any ideas? Thanks everyone!

[eluser]WanWizard[/eluser]
[quote author="extractortotem" date="1357335378"]I'm an absolute beginner in CI and DM ORM, and I had a quite serious struggle and frustration to get the 'nestedsets' extension working. May I post my notices/questions here, or should I open a new topic for it?
[/quote]
My personal opinion: whatever works for you. Posting in this thread might mix your question (and it's answers) in with others...

[eluser]WanWizard[/eluser]
@bwsewell,

Have you checked the logs for errors? A 500 is generated by the webserver, not normally by CI, I don't see an immediate reason why creating an object would cause such an error...

[eluser]kpi[/eluser]
Hey wanwizard, thanks for all your work and support for Datamapper. It has really made my life simpler Smile

I recently upgraded my virtual development ubuntu box, upgraded from 11.04 to 12.04, did all the apache, php, mysql upgrades and cloned one of my major projects from my git repository.

Everything seems to be working fine but I get this error message at the top of every page.

Code:
A PHP Error was encountered

Severity: Warning

Message: include(application/third_party/config/datamapper.php): failed to open stream: No such file or directory

Filename: core/Config.php

Line Number: 115

A PHP Error was encountered

Severity: Warning

Message: include(): Failed opening 'application/third_party/config/datamapper.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear')

Filename: core/Config.php

Line Number: 115

DM is installed as a spark and I have no idea why it's looking for it in the third_party folder. I haven't added the bootstrap code anywhere but it acts as if it's there. What's strange is DM is loaded and it works fine. Do you have any idea as to what might be happening?

Thanks

[eluser]jordanarseno[/eluser]
Hey WW and friends,

Just wondering if there is an easy way to autopopulate an object's related fields on an instance by instance basis rather than globally in the config file, or, for the entire class.

I'd like to include all related models for a single instance without chaining a ton of include_related() functions.
Something like this would be nice:

Code:
$x = new Model();
$x->include_all_related();

Any way to do this easily?

Thanks as always!




Theme © iAndrew 2016 - Forum software by © MyBB