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]
  • #151 / Apr 08, 2010 11:35pm

    Alface

    41 posts

    @Alface
    The HTMLForm extension is no longer supported or being updated.

    Feel free to modify the extension directly.

    O.O

    But but but.. it is so important O.O

    anyway, just to know, how could I modify the extension without doing it directly?

  • #152 / Apr 12, 2010 4:21am

    rideearthtom

    21 posts

    Quick question - should I be setting up cascade rules for deleting records in join tables in my database? Or is that going to make DMZ throw a wobbly when it does its automatic relation deleting routines? Should I set NULL on cascade instead?

  • #153 / Apr 12, 2010 4:56am

    jpi

    55 posts

    Short answer : the second option. (with NULL column)

  • #154 / Apr 12, 2010 7:25am

    OverZealous

    1030 posts

    @rideearthtom
    For in-table foreign keys, use NULL, but for join tables, you can safely use cascade rules if you prefer.  However, they will most likely never run, since DMZ manually deletes all relationships first before deleting an item.

  • #155 / Apr 12, 2010 8:09am

    rideearthtom

    21 posts

    Thanks!

  • #156 / Apr 14, 2010 12:05pm

    tomdelonge

    60 posts

    Join fields are confusing me. I have a many to many relationship. In the view file, I have a foreach loop that should include the join column. I know I need to use the “include_join_fields()” method and “get()” method both within the foreach loop so it does it each time. However, the way I have it now it just gets the same value every time.

    This is in my foreach loop:

    foreach($ys->all as $y)
    {
    $x->y->include_join_fields()->get();
    $value = $x->y->join_value;
    
    echo $value;
    }

    Basically, I can see why it’s the same value every time. I just need to narrow my query to say “when x is related to the current $y in the loop (not just the Y model)”.

    Any ideas? I’m sure I’m just missing something simple…

  • #157 / Apr 14, 2010 12:58pm

    bEz

    110 posts

    nvm

  • #158 / Apr 14, 2010 1:23pm

    TheJim

    35 posts

    This is in my foreach loop:

    foreach($ys->all as $y)
    {
    $x->y->include_join_fields()->get();
    $value = $x->y->join_value;
    
    echo $value;
    }

    I don’t have a lot of time to try to set up something similar and make sure I know exactly what you’re getting at, but what is clear is that you’re not using $y, which is of course the changing value.

    So, I would think that at least you’d want

    foreach($ys->all as $y)
    {
    $y->x->include_join_fields()->get();
    $value = $y->x->join_value;
    
    echo $value;
    }

    That is, switching the y and the x (assuming x is also your model name and not just a variable name).

    And of course I don’t really know what you’re doing, but in all likelihood you could set up your query such that you don’t have to do another get() in the loop.  That’s a separate issue though.

  • #159 / Apr 14, 2010 3:06pm

    tomdelonge

    60 posts

    I figured it out. Many to Many with join fields was confusing me, but I should have been doing the query on the opposite model (Thanks to TheJim).

  • #160 / Apr 14, 2010 5:36pm

    bEz

    110 posts

    Glad you resolved it, I was bothered with work here when I was going to try and assist you.  :D

  • #161 / Apr 15, 2010 3:42am

    tdktank59

    322 posts

    Wow!

    See what happens when I take a bit of a break from my personal development and just focus on my day job…
    Now I am completely lost in what I is new 😊

    From what I can tell (mind you I loved DMZ in the first place) I will love this version even more 😊

    Now to go read the docs and start wrapping my head around this new version.

    You have a beer fund that we can donate to? You have done great work and continue to.
    So from at least me, but pretty sure many many others Thanks for the great work!

  • #162 / Apr 15, 2010 6:30am

    rideearthtom

    21 posts

    Having some problems with subqueries here.

    I can’t find anything wrong with this code:

    $accepted_documents = new Document();
    $accepted_documents->select('id')
        ->where_related('sme_profile', 'id', $this->sme_profile->id);
    $documents = new Document();
    $documents->where_not_in_subquery('id', $accepted_documents)
        ->get();

    But it generates an SQL error:

    Unknown column ‘tdb_documents_subquery.id’ in ‘field list’

    Am I missing something? I can’t see any table alias ‘tdb_documents_subquery’ being specified in the subquery…

  • #163 / Apr 15, 2010 6:58am

    rideearthtom

    21 posts

    I’ve done a temporary fix by filling an array with the offending sub-query’s results and adding where_not_in if count() > 0.

    But it seems strange that other subquery types work OK.

    Here’s the full code, with the working subqueries, and with the broken one replaced with the fix above. The above post was a simplification of the problematic subquery. Maybe this is a DMZ problem, I don’t know.

    private function has_documents_to_accept()
        {
            $accepted_documents = new Document();
            $accepted_documents->where_related('sme_profile', 'id', $this->sme_profile->id)
                ->get();
            $ids_1 = array();
            foreach ($accepted_documents as $item)
            {
                $ids_1[] = $item->id;
            }
            $products_purchased = new Product();
            $products_purchased->select('id')
                ->where_related('purchase', 'sme_profile_id', $this->sme_profile->id);
            $join_projects_purchased = new Join_documents_locations_project();
            $join_projects_purchased->select('id')
                ->where_related('project/purchase', 'sme_profile_id', $this->sme_profile->id)
                ->where('location_id', $this->sme_profile->location_id);
            $documents = new Document();
            $documents->where_related_subquery('product', 'id', $products_purchased)
                ->or_where_related_subquery('join_documents_locations_project', 'project_id', $join_projects_purchased);
            if (count($ids_1) > 0)
            {
                $documents->where_not_in('id', $ids_1);
            }
            return $documents->count() > 0 ? TRUE : FALSE;
        }
  • #164 / Apr 15, 2010 2:44pm

    modano

    32 posts

    Hi guys,

    How do I go about removing something on an update, for example:
    I create a new “user” and set first name and last name.
    Later I change my mind and want to remove the last name, I only want the first name available in the database.
    So I display the current first name and last name on a form in a view, and clear the text field “last name” and hit the submit button.


    As DMZ will not validate empty fields on updates, but instead treating it as keep the value currently in the database/object, how do I in above example CLEAR the last name in the database?

    regards,
    modano

  • #165 / Apr 15, 2010 4:02pm

    bEz

    110 posts

    Why not run a routine that will simply assign “NULL” (on-demand) for a particular {USER} without using a text field.

    $someObject = new aModel($this->input->post('user_id');
    if ( $someObject->exists() ) {
      $someObject->last_name = NULL;
      $someObject->save();
      .
      .   // log/notify results of save routine
      .
    
    } else {
     . . .  // log/notify bad user id
    }

    You may also need to remove validation (“required”) from the last name field, or turn-off validation for this particular routine assignment…

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

ExpressionEngine News!

#eecms, #events, #releases