ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

November 23, 2009 11:54pm

Subscribe [46]
  • #76 / Dec 16, 2009 2:16am

    OverZealous

    1030 posts

    LOL - Thanks for the laugh and the support.  It’s really appreciated!

  • #77 / Dec 16, 2009 2:30am

    OverZealous

    1030 posts

    I’ve posted a poll to help gauge DMZ’s user base.

    If you don’t mind, clicky on over here, and pick an option!

    Thanks!

  • #78 / Dec 16, 2009 7:39am

    rideearthtom

    21 posts

    Hi, and thanks for the great work you’ve done. This is exactly what I was looking for.

    Just a quick question - I’ve created a simple class, and in my controller I’m calling get_where on it. I can use the resulting object properties no problem.

    I passed the object directly to my view and for the sake of development I called var_dump() on the object to output the data for checking.

    To my great surprise, my machine froze up, and a few minutes later I had a monolithic array on screen in my browser, thousands of lines, seemingly containing every piece of information about every element of my CodeIgniter installation, all my config variables, everything.

    I don’t think that’s normal - is it?

    Could it be because I’m using non-DataMapper models for authentication? (I’m using ReduxAuth, and it seems to be spitting out a lot of Redux stuff as well.)

    Do you think I’ve misconfigured something? I know in the manual you say to clear out the autoload models array, but I need to keep my ReduxAuth model in there at least…

  • #79 / Dec 16, 2009 7:42am

    OverZealous

    1030 posts

    Please see the troubleshooting section of the docs.

  • #80 / Dec 16, 2009 7:51am

    rideearthtom

    21 posts

    I did, but the first time round I failed to notice the entry dealing with var_dump… whoops! Sorry…

  • #81 / Dec 17, 2009 12:18am

    tdktank59

    322 posts

    Thought id share it with you guys…

    Spanish Translation of the datamapper lang file

    DMZ 1.6.1 - Spanish lang File

    Enjoy

  • #82 / Dec 17, 2009 3:43am

    chadbob

    11 posts

    I understand looping through the returned objects of a

    $_->get();

    query with a foreach.

    How would I directly access those objects though if I knew the index?

    In my model, I have it set up to auto sort by date, so before I massage all the sets, let’s say I need to get the id of the most recent report. 

    How would I do something along the lines of:

    $_->get();
    $_->0->id;

    ?


    Sorry, I know this is probably a basic php question, I’m coming from Java and all this arrow business is a bit odd to me :o

  • #83 / Dec 17, 2009 4:05am

    OverZealous

    1030 posts

    @chadbob

    When you use foreach($objects as $o), it is simply acting on an Iterator interface that DMZ provides.  The Iterator is iterating over the magic all array (which is indexed from 0 in DMZ).

    Therefore, you simply use the indexed on the all array, like so:

    $object = new Object();
    $object->get();
    // get the 3rd item
    $object3 = $object->all[2]; // 0-indexed

    I come from a Java background too, and I still write some Java code.  Switching between the two causes a lot of headache at times.

    Some random Java to PHP tips:

    // Java => PHP
    object.property => $object->property
    object.method() => $object->method()
    "string" + "string" => "string" . "string"
    super.method() => parent::method()
    MyClass.staticMethod() => MyClass::staticMethod()
    public String toString() => public function __toString()

    Be careful when comparing values.  PHP is really loose about values:  In PHP, these are == to FALSE: 0, ‘’, NULL.  If you need to compare to false explicitly, you need to use ===.  Also, always use is_null when checking for NULL values.

    Arrays are an all-in-one combination of ArrayList and HashMap.  They can be accessed via keys, or iterated over.  The order objects are inserted is preserved, or they can be sorted.

    Objects can have properties created at runtime.  More importantly, there are magic methods that allow the object to dynamically process variables and methods that aren’t explicitly defined in the class.  DMZ takes advantage of this.

    Good Luck, and welcome to the wild-and-crazy world of PHP.  It can be really fun, but when you first come across the subtle differences in in_array vs strpos, you may swear a little.  :lol:

  • #84 / Dec 17, 2009 4:07am

    OverZealous

    1030 posts

    Oh, I should have mentioned, if you only need the 3rd object from a result set, you can do this:

    $o = new Object();
    $o->where(...);
    $object3 = $o->get(1, 2); //start at item 2, limit to 1
  • #85 / Dec 17, 2009 4:29am

    chadbob

    11 posts

    Thanks Phil, how to access resultant array of objects by index is what I needed! (I still need to return all of the objects for processing.)


    Yes…php’s typing, arrays, etc drive me nuts!  Part of the problem is that I’m cutting my teeth on php+codeigniter+dmz at the same time..so I get confused as to what is general php syntax vs CI syntax vs DMZ syntax… 

    Since you said you do Java, you know that (if you do a lot of heavy OOP)  java’s insanely deep hierarchies of classes/interfaces also makes the move to MVC a bit odd as well.

    But I’m enjoying this nonetheless!  I’m sure my code is horrid, but it’s still far more elegant for dynamic pages pulling from a relational DB than I could do with “typical” java.


    Thanks again!  DMZ is great.

  • #86 / Dec 17, 2009 4:41am

    OverZealous

    1030 posts

    @chadbob
    Oh, yeah, the function-based tools vs object-based tools is very difficult to get used to.

    What’s bizarre, though, is that I still enjoy coding in PHP more than in Java. Even with better debugging tools, stricter (and easier to read) code in Java, PHP is just more fun to write.  😛

    A good IDE helps.  I’m still struggling along with Aptana 1.5 (2.0 effectively dropped PHP support 😠 ), but I’m looking into using NetBeans 6.  NB6 is insanely fast, and has incredibly smart PHP suggestions (including the ability to use comments to define the types for magic properties).

    However, NB doesn’t have a usable synchronizing toolkit, nor the ability to run command-line functions from the toolbar.

    I’m 75% of the way solving the first one, as I have written my own, developer-friendly standalone sync tool (in Java) that can be completely run from the command line or pop-up a GUI as needed, and stores sync properties in text files.  Currently it syncs between any combination of local filesystem and SFTP (SSH+FTP) connections.  I’ll eventually release it to the world.

    The second problem is a much bigger issue, since I currently have a bunch of little utilities I run in Aptana, like JavaScript compressing.  Until I solve that, I can’t really switch away from Aptana.

  • #87 / Dec 17, 2009 4:43am

    tdktank59

    322 posts

    Hey got a question.
    Has nothing to do with dmz however lol..

    http://lgb.421entertainment.com/es/customers

    Im running UTF-8 however for some reason it’s not printing the proper values. In the database its stored in utf8-general-ci. and looks fine there however it wont print right…
    Any idea how I can do that?

    EDIT: Never mind just had to set

    <meta http-equiv=“content-type” content=“text/html; charset=utf-8” />

    PS. THe page before this one there is a Spanish translation of the language file.

  • #88 / Dec 17, 2009 4:46am

    OverZealous

    1030 posts

    Well, first off, your HTML doesn’t have the correct encoding.  You’ll either need to add it as a header, or as a meta tag in your document.

    Also, your HTML is all messed up.  You’ve got script and link tags before the DocType.  The DocType must be first.  (Actually, you’ve got the the <?xml?> declaration, which should be first, but I believe it is recommended to not use that, even on XHTML, unless you are actually generating an XML document.)

  • #89 / Dec 17, 2009 4:47am

    OverZealous

    1030 posts

  • #90 / Dec 17, 2009 4:48am

    tdktank59

    322 posts

    Well, first off, your HTML doesn’t have the correct encoding.  You’ll either need to add it as a header, or as a meta tag in your document.

    Also, your HTML is all messed up.  You’ve got script and link tags before the DocType.  The DocType must be first.  (Actually, you’ve got the the <?xml?> declaration, which should be first, but I believe it is recommended to not use that, even on XHTML, unless you are actually generating an XML document.)

    damn didnt notice that.

    Thanks for seeing that lol…
    Yeah ill be removing the xml doc tag thing…
    And the script/link tags are supposed to go at array array below all the links and stuff

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases