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]
  • #91 / Dec 17, 2009 6:31am

    mrtavo

    15 posts

    Greetings,

    I have a question that I can’t resolve through the user guide.

    If I do a query like this ...

    SELECT <fields>
    FROM <table>
    LEFT JOIN <tableX> as <X>
    .
    .
    .
    WHERE
    (Case logic 1) AND
    (Case Logic 2) AND
    (
      (Case Logic 3) OR
      (Case Logic 4)
    )

    It should be something like:
    $ variable = new Model ();
    $ variable-> where_related_ ( ‘Model2’, ‘field’, ‘value’); // case logic 1
    $ variable-> where_related_ ( ‘model3’, ‘field’, ‘value’); // case logic 2
    .
    .
    .
    How do I add this?

    AND
    (
      (Case Logic 3) OR
      (Case Logic 4)
    )

    Should be a subquery? The truth is that I haven’t got this very clear.

  • #92 / Dec 17, 2009 6:38am

    OverZealous

    1030 posts

    @mrtavo

    Are you just looking for Query Grouping?

  • #93 / Dec 17, 2009 6:41am

    mrtavo

    15 posts

    Sorry, I reply myself, I had not seen the ability to group consultations.

    Sorry for the inconvenience.

  • #94 / Dec 17, 2009 9:28am

    cube1893

    18 posts

    Hi guys,

    I’m experiencing unexpected results when using a many-to-many relationship on my Application and Course tables.

    The process of adding elements works perfectly, but when the relationship gets updated, the old relationships remain in the table apllication_course.

    Example:

    1. These are the relationships after an application has been created.

    application_id |  course_id
    ----------------------------
    1              |  87
    1              |  101


    2. After that, a new course with id 55 is assigned to the application, all other course_ids should be deleted. But the result ist:

    application_id |  course_id
    ----------------------------
    1              |  87
    1              |  101
    1              |  55

    and should be:

    application_id |  course_id
    ----------------------------
    1              |  55

    How can I accomplish this? I’d appreciate any help!

  • #95 / Dec 17, 2009 11:47am

    Mirage

    273 posts

    You’ll have to delete existing courses first before assigning new ones.

  • #96 / Dec 17, 2009 12:09pm

    cube1893

    18 posts

    How can I delete these courses? I don’t want to delete the courses but the relationships between an application and different courses.

  • #97 / Dec 17, 2009 12:14pm

    cahva

    662 posts

    EDIT:

    Resolved. Duh! What a moron I’am 😊 Country should ofcourse be one-to-many with addressbooks! So changing $has_one = array(‘addressbook’) to $has_many = array(‘addressbook’) solved the problem. I’ll crawl back to the cave now :D

    Hi,

    I have a problem saving relation addressbook->country.

    Theres 3 tables, customers, addressbooks and countries. Customer can have several addressbooks, addressbooks can have single country. Problem is now that when I have 2 addressbooks and try to save the same country to both of them, other one gets wiped out!

    First heres the update that DMZ is doing:

    UPDATE `addressbooks` SET `country_id` = NULL WHERE `addressbooks`.`country_id` = 72 AND `addressbooks`.`id` <> ‘1’
    UPDATE `addressbooks` SET `country_id` = 72 WHERE `id` = ‘1’

    (so apparently it is first setting all addressbooks country_id to NULL with the same country_id)

    And the code:

    if ($this->input->post('save_address'))
    {
        $abook = new Addressbook();
        $abook->get_by_id($this->input->post('addressbook_id'));
        
        if ($abook->exists() && $this->data['customer']->id == $abook->customer_id)
        {
            $country = new Country();
            $country->get_by_id($this->input->post('country'));
            
            if ($country->exists())
            {
                $abook->from_array($_POST,array('name','company_name','company_id','address1','address2','zip','city'));
    
                if ($abook->save($country))
                {
                    $data['message'] = lang('account.address_saved');
                }
                else
                {
                    $data['message'] = lang('account.address_could_not_be_saved');
                }
            }
            else
            {
                $data['message'] = lang('account.invalid_country');
            }
        }
        else
        {
            $data['message'] = lang('account.address_could_not_be_saved');
        }
    }

    Addressbook and country are related to eachother with $has_one.

    I know how to circumvent the problem(set the country_id manually when saving address) but I’m sure there is something Im missing here 😊

  • #98 / Dec 17, 2009 2:01pm

    janus303

    10 posts

    Minor documentation request—there’s a lot of power in the included extensions, and I find myself RTFM’ing them a lot. It would be nice to see those listed in the table of contents under a section to make them easier to find, rather than having them just linked from the “Included extensions” item of the “extending DataMapper” section.

    My carpal tunnel wrist would bless you a thousand different ways for the reduced mouse clickage. 😊

  • #99 / Dec 17, 2009 2:12pm

    janus303

    10 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.

    I’ve settled on Komodo IDE, which is the only IDE I could get to reliably work with a remote debugger (XDebug). I think it has most of the things you’re looking for. And it’s fast (written in the Mozilla XUL framework I believe).

    For synchronizing I use Unison. It’s really quite slick, and sounds like what you’re doing. I think Komodo has some stuff but I have Unison set up to sync the log files back to my local machine so I can use the Mac’s Console.app to view them as I debug, so it makes sense to have Unison take care of synchronizing the code base as well.

  • #100 / Dec 17, 2009 3:51pm

    OverZealous

    1030 posts

    How can I delete these courses? I don’t want to delete the courses but the relationships between an application and different courses.

    Use delete($related).  It does not delete the objects in this format, just the relationship.

  • #101 / Dec 17, 2009 4:12pm

    OverZealous

    1030 posts

    @Michael Ditto

    What about bookmarking the page you use? 😉  I have two reasons for not breaking them out:

    1) The TOC is already getting pretty busy.

    2) I don’t really like supporting the extensions, so I hide them. 😊

    ——————————

    Thanks for the suggestions.

    As for Komodo - $300 is a bit steep for me right now.  My budget currently limits me to software that costs $0 or less.  😊

    I downloaded and tried Unison before I began writing my own.  I can’t remember what I didn’t like about it.  I’ve looked over the docs again, and it seems like I might be able to use it.  But I remember feeling there was some serious shortcomings in it.  (Part of it is NIH-syndrome, of course.)

  • #102 / Dec 17, 2009 4:41pm

    cube1893

    18 posts

    Thanks. I’m learning more every day - your plugin is awesome!

  • #103 / Dec 18, 2009 1:36am

    tdktank59

    322 posts

    Minor documentation request—there’s a lot of power in the included extensions, and I find myself RTFM’ing them a lot. It would be nice to see those listed in the table of contents under a section to make them easier to find, rather than having them just linked from the “Included extensions” item of the “extending DataMapper” section.

    My carpal tunnel wrist would bless you a thousand different ways for the reduced mouse clickage. 😊

    Make some book marks for yourself! (click and drag to the bookmark bar or Ctrl+d in windows splat+d mac)

  • #104 / Dec 18, 2009 3:42pm

    janus303

    10 posts

    Make some book marks for yourself! (click and drag to the bookmark bar or Ctrl+d in windows splat+d mac)

    Thanks, I actually do know how a browser works. My main point was that this is good functionality that’s hard to find the documentation for.

  • #105 / Dec 18, 2009 3:46pm

    tdktank59

    322 posts

    Make some book marks for yourself! (click and drag to the bookmark bar or Ctrl+d in windows splat+d mac)

    Thanks, I actually do know how a browser works. My main point was that this is good functionality that’s hard to find the documentation for.

    Wasn’t trying to say your dumb… The fact that you are using this and programming shows you have at least the basics of computers down!

    Yeah but it is linked under extensions…
    In my mind the extensions are a extra thing.
    Its the same concept with CI, all these libraries we are using are in a way extensions. You dont see them in CIs user guide

    Not to argue they are great things to have. I use the HTML/Array extension when I can!

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

ExpressionEngine News!

#eecms, #events, #releases