CodeIgniter Forums
DMZ 1.7.1 (DataMapper OverZealous Edition) - 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: DMZ 1.7.1 (DataMapper OverZealous Edition) (/showthread.php?tid=28550)



DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-22-2010

[eluser]OverZealous[/eluser]
@NachoF

I don't know what to tell you. If you set the field to an empty string, then DMZ has to assume you want to save it. An empty string is not a NULL, and when inserting new data, DMZ only excludes NULLs from the query.

The best solution is to not set fields you want to be NULL to an empty string.

Also, if a field is EMPTY (not necessarily NULL), but not required, the validation routine will not run for that field. There is a workaround for this in the latest DMZ: the always_validate rule. It works like required, but doesn't through an error on empty strings.

You could add a rule that sets the default value if the string is empty, and then add the always_validate rule to ensure it runs. (Or you could add a rule that sets the value to NULL if empty, but the numeric rule will probably barf on NULL, so you'd have to override that one as well.)


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-24-2010

[eluser]Enorog[/eluser]
Hello Phil & fellow DMZ-ers. I'm migrating from Doctrine 1.2 to DMZ and what I've seen so far is wonderful! Doctrine has a lot of power, but it's hidden deeply and not really logical - after seeing DMZ in action I'm willing to give up my painfully achieved Doctrine veteran status and just take a clean start. Thank you for your efforts!

My first question - I'm trying a little "hello world" and I cannot find the SQL code for the tables you use in your examples (http://www.overzealous.com/dmz/pages/gettingstarted.html). Am I supposed to reverse-engineer the table structure? It would certainly be nice if you could provide this code to eliminate errors when starting up.

The second thing is - I'm using HMVC (Modular Extensions - http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/). Do you know if it will interfere with DMZ? I'm thinking about putting all my DMZ models in /application/models and everything else (the M of MVC) in HMVC triads under /application/modules.

Thanks!


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-24-2010

[eluser]NachoF[/eluser]
I know Phil doesnt want to support the html form plugin anymore but will anyone else help me out?? I recently uploaded my app to a server which has php 5.1.6 and suddenly the magic method __toString doesnt seem to be working.. on my dropdown options I get a bunch of Object id #40...
after some googling the only thing I could find was this
http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/

so, any idea on how can I fix it?? upgrading is not an option.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-24-2010

[eluser]Daniel H[/eluser]
I'm really worried that I'm doing something really stupid here but I can't get a complex relationship to work.

An Event can be related to many Images, and also can related to one Thumbnail (which is an Image).

In my database, an Event has a thumbnail_id field.

In my Event model:

Code:
var $has_one = array(
        'created_by' => array(
            'class' => 'user',
            'other_field' => 'created_event'
        ),
        'edited_by' => array(
            'class' => 'user',
            'other_field' => 'edited_event'
        ),
        'thumbnail' => array(
            'class' => 'image',
            'other_field' => 'event_thumbnail'
        ),
        'venue'
    );

and in my Image model:

Code:
var $has_one = array('event',
        'event_thumbnail' => array(
            'class' => 'event',
            'other_field' => 'thumbnail'
        ));


Yet when I save the thumbnail relationship, I'm getting, "Unable to relate image with thumbnail.". Not sure where I'm going wrong here... Anything obvious?


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-24-2010

[eluser]OverZealous[/eluser]
[quote author="Enorog" date="1274745722"]I'm trying a little "hello world" and I cannot find the SQL code for the tables you use in your examples (http://www.overzealous.com/dmz/pages/gettingstarted.html).[/quote]

That page is a leftover piece from the original datamapper. While I don't have exact pieces for those samples, if you look at the example app, included with the full download, nearly the same code was used for that app. That's a more complete application. Smile
Quote:I'm using HMVC ... Do you know if it will interfere with DMZ?

I can't answer this, but there have been discussions about it in the past. Use the search in the manual, it will also search the forums!


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-24-2010

[eluser]OverZealous[/eluser]
@Daniel H

That error tells me that you are trying to save a thumbnail on the image object. The image object can only accept a relationship of type event_thumbnail.

Ex:
Code:
// WRONG
$image->save(array('thumbnail' => $event));

// RIGHT
$image->save(array('event_thumbnail' => $event));


// WRONG
$event->save(array('event_thumbnail' => $image));

// RIGHT
$event->save(array('thumbnail' => $image));



DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-25-2010

[eluser]Daniel H[/eluser]
Sigh - thanks so much Phil. Very tired eyes didn't even spot that. Sorry to waste your time!


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-25-2010

[eluser]Enorog[/eluser]
Thank you Phil, I got everything working!

The HMVC solution on the forums you mention is in regards to Modular Separation (the HMVC in that name is a mistake, it's just a "organizing your modules" kind of library).

I can report that DMZ works without problems with Modular Extensions for CI. It's even nicer that way, because the only files in the regular CI models folder are DMZ classes, while you put the MVC models under MVC triads in /modules anyway.

And the more I try DMZ, the more impressed I am. You should look at Doctrine one day just to feel better about yourself! Smile

Jure


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-30-2010

[eluser]iancant[/eluser]
Storing Additional Information on the Join Table

Hi I am having some issues using DMZ. The documentation both online and in the download refers to this being possible, however don't provide any suggestions or examples on how to do it.

DataMapper DMZ: Advanced Relationships

I know it may seem an odd request however large parts of my application require me to save an additional piece of information (ie. a number or string) along with the relationship.

Also the colours on the page to help with explaining The Extended Relationship Attributes seem to have got out of sync.

Thanks in advance.

Ian


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 05-30-2010

[eluser]OverZealous[/eluser]
@lancant

See Working with Join Fields.

The colors seem fine to me.