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]
  • #856 / Mar 17, 2011 11:54am

    I have read the validation rules but what If i want to save a fields value in encrypted format but it should be displayed in normal way.

    like

    $u=new User();
    $u->Name='name';
    $u->Password='password';  // From validation rule I want it to encrypt
    $u->save();
    
    echo $u->Password; // Automatically decrypted from either same encrypt function (some way is needed to knwo weather we are getting or settting) or by another function for get time applicable
  • #857 / Mar 17, 2011 3:23pm

    WanWizard

    4475 posts

    To encrypt on save, see the prepping example in the documentation, it uses encrypt() as an example.

    To decrypt on retrieval, read the section in the manual about “Get Rules” (http://datamapper.wanwizard.eu/pages/getrules.html).

  • #858 / Mar 23, 2011 12:15pm

    rrpero

    1 posts

    Hello,

    Im trying to use a group_by and a get_paged together, but when i use, the $object->paged->total_rows returns to me the total rows of the first group in the result.

    example:
    $object->group_by(‘value’);
    $object->get_paged($start, $lines_page, true);

    if the first row has 12 objects grouped and the result of the query has 2 rows, the $object->paged->total_rows returns to me 12 but the result should be 2. Am i doing something wrong?

  • #859 / Mar 23, 2011 5:01pm

    WanWizard

    4475 posts

    Have you tested this with the latest version? DMZ 1.7.x is no longer officially supported.

    If so, and it is still a problem, please create an ticket at https://bitbucket.org/wanwizard/datamapper/issues, describing the problem and linking back to your message here ( #857 in the titlebar on right gives you the correct link)?

  • #860 / Mar 30, 2011 10:34am

    Dennis Rasmussen

    601 posts

    This is just ridiculous…
    Could someone explain to me what kind of method they would use to do such a simple thing (yet so complicated with Datamapper) as being able to create/edit a row in table_1 while creating/updating relations to table_2 with a many:many relation?

    table_1
    id - name
    
    table_2
    id - title
    
    table_3 (join table)
    id(1) - id(2)

    So basically I’m having:
    - A controller to handle the create/update behavior
    - 2 models for the tables, both related to each other as many:many
    - A view with a formula with name input for table_1 and a multiselect element having options from table_2

    When I submit I’d like the following to happen:
    - Create a new row in table_1
    - Create rows in table_3 with relations between the new row in table_1 and the multiselected rows in table_2

    All of this can easily be done without Datamapper, so why can’t I with Datamapper?
    Sure I could just do the following, but that seriously can’t be healthy for the server with all these objects being created for each relation?

    foreach($this->input->post('multiselect') as $key => $id)
      {
        $t2 = new Table_2($id);
        $t1->save($t2);
      }

    Note that the variable names are changed for simplicity.

  • #861 / Mar 30, 2011 6:17pm

    WanWizard

    4475 posts

    You’re using an ORM, so don’t complain it uses Objects. That’s how it works. 😉

    Having said that, I understand your question. Could you please add this as a feature request: http://bitbucket.org/wanwizard/datamapper/issues (and add a link back to your post), I’ll see if I can squeeze it in for the next update…

  • #862 / Jul 01, 2011 5:39am

    Haqqi

    15 posts

    I use DM 1.8.1-dev with HMVC

    I need some localizations using 2 or more languages. But I have a problem while adding language for DM Model. After that, I do a change just like below:

    class DM_Lang extends MY_Lang

    The language could be load with no problem. But one feature that won’t search for right language folder is when I try to load other model from other module. It won’t automatically find the right language folder for that model (which is in another module).

    Any solution?

  • #863 / Jul 01, 2011 1:04pm

    WanWizard

    4475 posts

    I don’t use HMVC, so I can’t help you.

    MX creates a new CI instance, under which your module controllers run. This instance instantiates MX_Lang as $this->lang, which is then used in your controllers.

    You can try changing the DM_Lang class in libraries/datamapper.php to extend MX_Lang instead of CI_Lang, so Datamapper can use MX’s $this->lang->load() method.

  • #864 / Jul 01, 2011 1:30pm

    Haqqi

    15 posts

    Yes, I did it. I always load some required modules just like

    DataMapper::add_model_path(
            array(
              APPPATH . 'modules/user'
            )
        );

    but whenever I access other modules, for example “post” module, it give an error, cannot find the required language for user model (I place the model_user_m_lang.php in modules/user/language/english folder).

    My MY_Lang already extends MX_Lang from HMVC without any addition.

    What I think that may be a problem is lang() method in MX_Lang. It uses only active modules to get additional language folder:

    $_module = CI::$APP->router->fetch_module();
    list($path, $_langfile) = Modules::find($langfile.'_lang', $_module, 'language/'.$idiom.'/');

    How can I get other loaded language file from DataMapper loaded model?

  • #865 / Jul 01, 2011 2:07pm

    WanWizard

    4475 posts

    It is a restriction of MX that only files from active modules can be accessed.

    You can try working around this by manually registering your module using $this->load->_add_module_paths($module).

  • #866 / Jul 01, 2011 2:45pm

    Haqqi

    15 posts

    it doesn’t work, the language won’t be loaded. Because i need it quickly, I just create override method in DM_Lang just like this:

    function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') {
        if (is_array($langfile)) {
          foreach ($langfile as $_lang)
            $this->load($_lang);
          return $this->language;
        }
    
        $deft_lang = CI::$APP->config->item('language');
        $idiom = ($lang == '') ? $deft_lang : $lang;
    
        if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE))
          return $this->language;
    
        $_module = CI::$APP->router->fetch_module();
        list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
        
        if($path === FALSE) {
          foreach(DataMapper::get_loaded_model_path() as $path_on) {
            list($path, $_langfile) = Modules::find($langfile. '_lang', rtrim(str_replace(APPPATH.'modules/', '', $path_on), '/'), 'language/'.$idiom. '/');
            if($path !== FALSE) {
              break;
            }
          }
        }
        
        if ($path === FALSE) {
          if (($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)))
            return $lang;
        } else {
          if (($lang = Modules::load_file($_langfile, $path, 'lang'))) {
            if ($return)
              return $lang;
            $this->language = array_merge($this->language, $lang);
            $this->is_loaded[] = $langfile . '_lang' . EXT;
            unset($lang);
          }
        }
    
        return $this->language;
      }

    You see that I add these lines:

    if($path === FALSE) {
          foreach(DataMapper::get_loaded_model_path() as $path_on) {
            list($path, $_langfile) = Modules::find($langfile. '_lang', rtrim(str_replace(APPPATH.'modules/', '', $path_on), '/'), 'language/'.$idiom. '/');
            if($path !== FALSE) {
              break;
            }
          }
        }

    in case if the first try won’t return good result. Of course it will make the process longer, but I really need it quickly. If you have any other better options, I will be glad using it.

  • #867 / Jul 01, 2011 3:33pm

    WanWizard

    4475 posts

    From the looks of it, MX only searches the current module, so nothing I can do here.

    You might want to take this up with @wiredesignz, to see if he sees a better solution.

  • #868 / Aug 21, 2011 10:49pm

    Jfly

    6 posts

    I upgraded CI from 1.7.x to 2.0 and then upgraded DMZ from 1.7.x to 1.8.1, now I got this:


    Fatal error: Call to protected method CI_DB_active_record::_reset_select() from context ‘DataMapper’ in ...\application\libraries\datamapper.php on line 1104

    What can I do for this?

    Thanks.

  • #869 / Aug 22, 2011 5:14pm

    WanWizard

    4475 posts

    That’s not CI 2.0, but probably 2.0.3.

    Datamapper doesn’t support CI (and Reactor) versions above 2.0. (I think 2.0.2, but I’m not sure).

  • #870 / Aug 22, 2011 5:18pm

    Jfly

    6 posts

    That’s not CI 2.0, but probably 2.0.3.

    Datamapper doesn’t support CI (and Reactor) versions above 2.0. (I think 2.0.2, but I’m not sure).

    You are right. I previously tried the last version of CI.

    Thanks a lot.

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

ExpressionEngine News!

#eecms, #events, #releases