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.

DMZ 1.7.1 (DataMapper OverZealous Edition)

March 14, 2010 11:43pm

Subscribe [104]
  • #76 / Mar 22, 2010 12:29pm

    OverZealous

    1030 posts

    @Oblique

    The reality of software development—and they don’t tell you this in college—is that writing code makes up at most 5-10% of your time.  Design and planning, for me, take up about 25%, testing and debugging probably 25-50%, and the leftover time is pretty much all documenting.*

    When I did the original rewrite of the DataMapper docs, it took me over 40 hours of work!  I still spend almost equal amounts of time managing the manual as I do the code.

    As far as I know, there is no way to make documentation fun.  If you like writing, that helps.  If you love your project, writing about it is a little exciting, because you get to show off your work.  Undocumented code might as well not exist; documented code is there for all the world to appreciate.

    Maybe if you think of it that way it helps.

    * Numbers in the post are completely made up.  Your numbers may vary based on actual time spent.  Project and team size can be a factor in determining your time usage.  Results not guaranteed.

  • #77 / Mar 22, 2010 12:41pm

    PoetaWD

    97 posts

    Thanks Phill!

    I will update my version!

    Thanks a lot man for the work! YOU ARE GREAT!

    Btw, what you think about making a website and a FORUM for DMZ ?

    http://www.dmzci.com  or cidmz.com ?

    I think its own forum would help to find questions that have being already answered… We could add extensions… tutorials… maybe a WIKI !

    If you are OK with it, I can help with the forum installation… moderation… even to pay for the domain !

    What you think ?

  • #78 / Mar 22, 2010 12:46pm

    Oblique

    32 posts

    @OverZealous
    Yeah, heard of it )
    Well, it was not so bad actually, just need to know some tools to make it faster.

    Automating things is fun ) It’s the only thing keeps me coding ) Well, i’m lying, appreciation is obligatiry too.

    I’m thinking about django now. Python really blew my mind when i heard of indentation block division. And then list comprehensions - i thought i was gonna dance right where i sit.

    Actually, what keeps me here is DMZ i think ) It’s real pleasure to use it )

  • #79 / Mar 22, 2010 12:57pm

    OverZealous

    1030 posts

    @Oblique
    For simple API-style documentation, you could try PHPDoc.  I’ve run it over DMZ; it makes a fairly decent (if not comprehensive) set of docs.

    If you’ve ever used javadocs, it’s the same idea.

    @PoetaWD
    I’m not sure I would want that at this time.  I like overzealous.com/dmz.  I don’t want a whole forum, because I just can’t deal with responding to multiple threads. :lol:  Currently, the amount of communication I get from DMZ is still handled well by the current situation.

    In reality, I think there are only a couple hundred DMZ users in total.  They just happen to be an awesome, and passionate, group of users!  😛

    The only reason I would see spinning DMZ off onto its own domain is if I decided I couldn’t maintain it on my own anymore.  Then I would probably put it onto something like BitBucket, and give it over to the community completely.

    But thanks for the offer!  😊

  • #80 / Mar 22, 2010 1:02pm

    PoetaWD

    97 posts

    @Oblique
    For simple API-style documentation, you could try PHPDoc.  I’ve run it over DMZ; it makes a fairly decent (if not comprehensive) set of docs.

    If you’ve ever used javadocs, it’s the same idea.

    @PoetaWD
    I’m not sure I would want that at this time.  I like overzealous.com/dmz.  I don’t want a whole forum, because I just can’t deal with responding to multiple threads. :lol:  Currently, the amount of communication I get from DMZ is still handled well by the current situation.

    In reality, I think there are only a couple hundred DMZ users in total.  They just happen to be an awesome, and passionate, group of users!  😛

    The only reason I would see spinning DMZ off onto its own domain is if I decided I couldn’t maintain it on my own anymore.  Then I would probably put it onto something like BitBucket, and give it over to the community completely.

    But thanks for the offer!  😊

    I see and understand your point… No problem…  :cheese: !!

  • #81 / Mar 22, 2010 9:55pm

    Frank Liu

    10 posts

    DMZ’s main library file contains spl_auto_load function, which is not supported until PHP 5.1.2. So you may want to change server requirement to reflect this?

    Anyway, can I just remove the spl_auto_load statement and find another way to load the files? Do you have a recommended way to deal with this problem? I am using php 5.0.0.

    I did not realize that (I’ve thankfully never had to deal with PHP older than 5.2, because I use the JSON functions a lot!)

    I’ll take your suggestion and bump the requirements up to 5.1.2.  As for a work-around, all the spl function is doing is loading the models in as they are needed.  I know I “broke” the ability to load models via CI (which will be remedied with 1.7.1), but you can temporarily fix that by removing the private in front of the _assign_libraries function in the main library.  It’s near the bottom.

    Another option is to write your own helper or library, or even extension to DMZ that allows you to load the models in as needed.

    Sorry to hear about your work environment!  :shut:

    This is just to provide a small closure on this matter. So if you are using an older version of PHP that does not support spl_autoload_register, then you can do the following:

    In any of your config files, say config/autoload.php, append the following:

    function __autoload($class_name) {
        require_once(APPPATH.'libraries/datamapper.php');
        DataMapper::autoload($class_name);
    }

    Next comment out the line that uses the spl_autoload_register function in your libraries/datamapper.php file. This hack works for me.

  • #82 / Mar 22, 2010 10:08pm

    OverZealous

    1030 posts

    @Frank Liu
    Wow, that’s great!  Thanks for the research.

    I added a link back to your post on the System Requirements page so that others can find this if they need to.

    Hopefully you will be able to upgrade your PHP soon, though!

  • #83 / Mar 23, 2010 7:40pm

    PoetaWD

    97 posts

    Hey Phill,

    I have something to show you that I cant send in this forum.

    Is there a email where I can send you a message ?

    Thanks

  • #84 / Mar 23, 2010 8:27pm

    OverZealous

    1030 posts

    @PoetaWD
    It’s on the troubleshooting page of the manual, in the first gray box.

    (I don’t want to publish it on a public forum, obviously.)

  • #85 / Mar 23, 2010 11:18pm

    OverZealous

    1030 posts

    Code Theft

    I feel the need to write this.  I’ve been contacted by several individuals—in just the last few weeks—who have felt the need to share their pride in copying source code from proprietary and non-free applications.

    This is an incredibly misinformed view of the world.  Rationalizing this by saying you are just learning, or something similar, does not take away from the fact that:

      1) It is completely unnecessary.  There is a huge wealth of legally free software, with 100% visible source code to look at.

      2) It damages the entire software industry.  I assume that the majority of people who use CodeIgniter are in the software industry.  When you take from someone else’s hard work, and redistribute it against their will, you are stealing from that person or company.

      3) You don’t learn by doing things right the first time.  You learn by making mistakes.  This is the point of going to class, of practicing, of any skilled trade.  I don’t know how to write code because I saw it written correctly once before—I know how to write code correctly because I’ve written a lot of messed up crap that I had to rewrite many times.

      4) The saddest thing is when you do this, and then brag about it to a person who writes software for a living, that’s like going to an independent film director and bragging about how you download all your favorite movies from bittorrent.  That’s really nice.  Why don’t you spit in their face, too?

    Please, if you are trying to learn something, look at the open-source community.  Don’t steal closed-source code.  Just because you can decrypt PHP and JavaScript, doesn’t mean you should.  And don’t steal FOSS code either!  Attribute it, follow the licenses as provided, and be respectful of other software developers.

    As this isn’t the correct forum to discuss this, if you have a response to this message, we can continue the discussion here.

  • #86 / Mar 23, 2010 11:45pm

    Frank Liu

    10 posts

    So more Oracle woes…

    turns out whenever one tries to do a $o->save() that uses an insert, datamapper needs the following:

    // around line 1700 in libraries/datamapper.php
    // Create new record
    $this->db->insert($this->table, $data);

    if( ! $this->_force_save_as_new)
    {
    // Assign new ID
    $this->id = $this->db->insert_id(); // UNSUPPORTED for oci8 driver
    }

    Since the oci8 driver does not support this (Oracle doesn’t support auto incrementing keys), this would raise an error.

    To fix this put this around the same area:

    $query = $this->db->query(“select {$this->table}_SQ.NEXTVAL ID FROM DUAL”);
    $query_result = $query->row();
    $data[‘id’] = $query_result->id;

    // Create new record
    $this->db->insert($this->table, $data);

    if( ! $this->_force_save_as_new)
    {
    // Assign new ID
    $this->id = $data['id'];
    }

    Note that here we assume, for each table that one creates, there’s a corresponding sequence with the name ($table_name}_SQ.

    In addition, make sure that your oci8_result.php also contain the following code:

    function field_data()
    {
    $retval = array();
    $fieldCount = $this->num_fields();
    for ($c = 1; $c <= $fieldCount; $c++)
    {
    $F = new stdClass();
    $F->name = strtolower(ocicolumnname($this->stmt_id, $c)); // IMPORTANT
    $F->type = ocicolumntype($this->stmt_id, $c);
    $F->max_length = ocicolumnsize($this->stmt_id, $c);

    $retval[] = $F;
    }

      return $retval;
    }

    Generally, to make sure oci8 works properly, one really needs to change the driver to convert field names to lowercased. I wrote a separate thread in this forum somewhere else that contain some of those fixes.

    Anyway, did I mention I hate Oracle?

  • #87 / Mar 23, 2010 11:53pm

    OverZealous

    1030 posts

    @Frank Liu
    Wow.  I love PostgreSQL more every day 😜

    I’m glad you solved these problems.  I’m pretty sure there’s no way to integrate this into DMZ in a non-problematic manner.  😖

    If you don’t mind posting the link to the other thread, though, I’ll add a link to it to the DMZ docs.

    Edit: Corrected poorly written sentence.

  • #88 / Mar 24, 2010 12:26am

    Frank Liu

    10 posts

    @Frank Liu
    Wow.  I love PostgreSQL more every day 😜

    I’m glad you solved these problems.  I’m pretty sure there’s no way to integrate this into DMZ in a non-problematic manner.  😖

    If you don’t mind posting the link to the other thread, though, I’ll add a link to it to the DMZ docs.

    Edit: Corrected poorly written sentence.

    Here’s the link to the other thread. But these are just hacks; one should be careful about using them. Too bad I don’t know CI well enough to write a library. And it seems that CI is written in a way that is difficult to extend the database drivers.

  • #89 / Mar 24, 2010 12:36am

    OverZealous

    1030 posts

    And it seems that CI is written in a way that is difficult to extend the database drivers.

    That is, sadly, the biggest problem I have with CI.  If I could override them, I could easily fix all of my issues with _protect_identifiers.  I rather hate editing the core CI files directly.

    One thing: if you are only modifying the Oracle drivers (and not CI_DB, CI_DB_driver, or CI_DB_activerecord), you could try to copy the oracle drivers and give them a new name.  At least this way, upgrading CI wouldn’t override your customizations.  It’s probably not worth the renaming effort, though.

  • #90 / Mar 24, 2010 1:05am

    Frank Liu

    10 posts

    And it seems that CI is written in a way that is difficult to extend the database drivers.

    That is, sadly, the biggest problem I have with CI.  If I could override them, I could easily fix all of my issues with _protect_identifiers.  I rather hate editing the core CI files directly.

    One thing: if you are only modifying the Oracle drivers (and not CI_DB, CI_DB_driver, or CI_DB_activerecord), you could try to copy the oracle drivers and give them a new name.  At least this way, upgrading CI wouldn’t override your customizations.  It’s probably not worth the renaming effort, though.

    The problem is as far as I know, you do have to change the DB_active_rec.php file. The update and insert query executes a compiled string. This is not enough to properly deal with clob objects.

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

ExpressionEngine News!

#eecms, #events, #releases