EllisLab text mark
Advanced Search
55 of 64
55
   
DataMapper ORM v1.8.2
Posted: 15 November 2012 05:51 AM   [ Ignore ]   [ # 811 ]   [ Rating: 0 ]
Joined: 2011-01-27
6 posts

Thanks for the advice.

The reason I’ve done it the way that I have is that all trees / questions / answers (and also products, and product attribute values that I didn’t explain before) should have a full revision history so the admins can press a button and restore all of the values for those entities back to their previous state.  To my mind that means we need to store a revision ID for all of entities - what do you think?

What I was really looking for is a way to handle the copying of the entities and their relationships.  Is there a good way of doing that with DM ORM?

 
Posted: 15 November 2012 06:40 AM   [ Ignore ]   [ # 812 ]   [ Rating: 0 ]
Joined: 2012-10-31
5 posts

Hello WanWizard and congrats for DataMapper (it has speeded up my work). I have a question that maybe is answered in v2.0 input request, but want to clear any doubt. Let me explain: all my model objects extend DataMapper class and all of them share a set of methods. The question is obvious: I want to write those methods just once, is there any way to do this?

I’ve tried:

class MY_DataMapper extends DataMapper
{
   
public function my_shared_method()
   
{
      
// ...method stuff...
   
}

Then:

class Model_1 extends MY_DataMapper
{
   
// ...model stuff...

But error: “PHP Fatal error:  Class ‘My_DataMapper’ not found” appears.

Thanks in advance for any response.

 
Posted: 15 November 2012 07:44 AM   [ Ignore ]   [ # 813 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4420 posts

Where did you create MY_Datamapper? It should be library, not a model. If so, it should work fine, as CI deals with loading your extension.

But it’s better not to extend the Datamapper library at all, but instead work with a base model:

// ../application/models/model_base.php
class Model_Base extends Datamapper
{
    
// ...generic model stuff...

and

// ../application/models/model_i.php
class Model_I extends Model_Base
{
    
// ...local model stuff...

 

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 15 November 2012 08:26 AM   [ Ignore ]   [ # 814 ]   [ Rating: 0 ]
Joined: 2012-10-31
5 posts

It’s fine Harro, I had done exactly as you wrote, but name convetion was responsible for non-functioning. Actuallly my Model_Base was LB_Entity, stored in application/models/lb_entity.php

Renaming to Lb_Entity was enough.

Sorry for disturbing, as it would have worked from the begining if I had considered class naming convention.

Thanks for your time.

 
Posted: 22 November 2012 07:59 PM   [ Ignore ]   [ # 815 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-19
103 posts

Hello,

Is there a way to order by a related table ???

like:

$obj = new Product
$obj
->include_related('brand','name');
$obj->order_by('brand_name','desc');
$obj->get(); 

If not, is it possible using MYSQL query ???

Thanks

 
Posted: 23 November 2012 03:29 AM   [ Ignore ]   [ # 816 ]   [ Rating: 0 ]
Joined: 2011-12-09
13 posts
PoetaWD - 22 November 2012 07:59 PM

Hello,

Is there a way to order by a related table ???

like:

$obj = new Product
$obj
->include_related('brand','name');
$obj->order_by('brand_name','desc');
$obj->get(); 

If not, is it possible using MYSQL query ???

Thanks

$obj->order_by_related('brand','name','desc'); 

See http://datamapper.wanwizard.eu/pages/getadvanced.html#_related_model

 Signature 

Thanks for DataMapper !!!

 
Posted: 12 December 2012 05:27 AM   [ Ignore ]   [ # 817 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

Hey all,

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

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.

 Signature 

- Simon

 
Posted: 12 December 2012 10:53 AM   [ Ignore ]   [ # 818 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4420 posts

That is strange.

In the constructor all config properties are created from config, but only if they don’t exist yet:

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.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 12 December 2012 11:29 AM   [ Ignore ]   [ # 819 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

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:

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:

// 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?

 Signature 

- Simon

 
Posted: 31 December 2012 07:14 AM   [ Ignore ]   [ # 820 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-15
147 posts

Anyone want to help trying to port this lib to Laravel 4?

 
Posted: 04 January 2013 05:36 PM   [ Ignore ]   [ # 821 ]   [ Rating: 0 ]
Joined: 2012-12-30
4 posts

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

 
Posted: 05 January 2013 05:20 PM   [ Ignore ]   [ # 822 ]   [ Rating: 0 ]
Joined: 2011-04-22
1 posts

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:

$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!

 
Posted: 08 January 2013 03:22 AM   [ Ignore ]   [ # 823 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4420 posts
extractortotem - 04 January 2013 05:36 PM

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?

My personal opinion: whatever works for you. Posting in this thread might mix your question (and it’s answers) in with others…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 08 January 2013 03:24 AM   [ Ignore ]   [ # 824 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4420 posts

@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…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 11 January 2013 02:16 PM   [ Ignore ]   [ # 825 ]   [ Rating: 0 ]
Joined: 2010-04-30
4 posts

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.

A PHP Error was encountered

Severity
Warning

Message
: include(application/third_party/config/datamapper.php): failed to open streamNo 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')

Filenamecore/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

 
55 of 64
55