Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.0
#11

[eluser]WanWizard[/eluser]
@madwhistler,

I haven't had a look at htmlform. It's included but unsupported since Datamapper DMZ 1.7. I haven't got a clue what it actually does...
#12

[eluser]madwhistler[/eluser]
Right-o. Htmlform is quite nice but a bit buggy, it's an amazing prototyping time-saver to be able to whack out a screen form with a few extra validation lines and a single "build the form" call.

I've solved my problem, I think, with a front-end jQuery call to $(#myfieldid).val(selected-value). Simpler than trying to dig into the guts of htmlform, at least...
#13

[eluser]momsenmeister[/eluser]
Hi,

trying to get started with DataMapper, I face a weird problem.

All I try to do is this in my controller:

Code:
$e = new Testy();
$e->get();
var_dump($e);

But I end up with an endless output of pretty much all data that exists somewhere in my code igniter folders (including language files, config file with fully readable encryption key! and so on). How is that even possible to access these files?

This is the model:

Code:
<?php

class Testy extends DataMapper {

    var $table = 'event';
    
    //var $has_many = array('user');
    //var $has_one = array('city');

    function Testy()
    {
        parent::DataMapper();
        
        $this->validation = array
        (
          array(
              'field' => 'title',
              'label' => lang('wording_title'),
              'rules' => array('required'),
          ),
          array(
              'field' => 'date',
              'label' => lang('wording_date'),
              'rules' => array('required'),
          ),
          array(
              'field' => 'location_description',
              'label' => lang('wording_location_description'),
              'rules' => array('required'),
          ),
          array(
              'field' => 'datetime',
              'label' => lang('wording_datetime'),
              'rules' => array('required'),
          )
        );
    
    }
    
}

/* End of file testy.php */
/* Location: ./application/models/testy.php */

Any idea what I might be doing wrong?
#14

[eluser]The Hamburgler[/eluser]
momsenmeister var_dump is just doing its job, Check out the docs
#15

[eluser]The Hamburgler[/eluser]
I'm wondering what the best way is to save a new record to a large set of related records.

I want to save a new email record to all contacts it was sent to. The email could have thousands of recipients.

get_iterated() is great as it means i can load all these records from the db without running out of memory. However, this means i cant use:
Code:
$email->save($contacts->all);

As the all array is not set for iterated objects. Is there a nice way I can save an object to an iterated related object, or should i stick to looping though the related items
Code:
$email->save();

foreach($contacts as $contact)
{
    $email->save($contact);
}
#16

[eluser]momsenmeister[/eluser]
[quote author="The Hamburgler" date="1295467531"]momsenmeister var_dump is just doing its job, Check out the docs[/quote]

Thx a lot, my fault :-)

But unfortunately, I have a new question:
set_value() doesn't seem to work anymore?
I need it to repopulate my forms.
#17

[eluser]endielo[/eluser]
Hello everybody

Is DMZ support Single Table Inheritance?
Thank you

--
Endie Lo
#18

[eluser]WanWizard[/eluser]
If you refer to the way this is implemented in for example Rails, the answer is no.

I also think you should not want it, as you might collect all kind of data from the hierarchy you don't need.

Datamapper implements relations dynamically, so you get fetch a child, then use $child->parent->grandparent->get() to get related objects. You can also filter the relation using something like $child->parent->grandparent->where_related_grandparent('age', 80)->get().
#19

[eluser]endielo[/eluser]
WanWizard,

Thank You for your help

I'm a beginner. I'm very love DMZ & CI

--
Endie Lo
#20

[eluser]Ficoder[/eluser]
Hi,
Could somebody please explain me what are the cons for using this DataMapper ORM? Manual says "DataMapper is an Object Relational Mapper written in PHP for CodeIgniter. It is designed to map your Database tables into easy to work with objects, fully aware of the relationships between each other.".

Okay, but why / how is better using database as objects than making straight queries? Sorry about quite newbie questions, but i just wanted some easy examples straight queries vs. DataMapper pros / cons.




Theme © iAndrew 2016 - Forum software by © MyBB