Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.2

[eluser]WanWizard[/eluser]
You can't. Every line on this form will be a separate "email_type" object, which you need to create first.

[eluser]tarciozemel[/eluser]
[quote author="WanWizard" date="1335970993"]You can't. Every line on this form will be a separate "email_type" object, which you need to create first.[/quote]

OMG... So, how I do this, can you help me? :cheese:

[eluser]WanWizard[/eluser]
You'll have to write something for it, that creates new objects for every email address on the form, populate the object, save it and relate it to the company object.

There isn't something magical that takes your custom and very application specific data an turns it into database records... Wink

[eluser]tarciozemel[/eluser]
[quote author="WanWizard" date="1336002337"]You'll have to write something for it, that creates new objects for every email address on the form, populate the object, save it and relate it to the company object.

There isn't something magical that takes your custom and very application specific data an turns it into database records... Wink[/quote]

DM is almost! haha

Maybe in the v2 a little more magic happens to situations like that (which I believe is common)! We don't pay to dream... Smile

Anyway, very thank you!

[eluser]ckm5[/eluser]
I'm looking at implementing transactions, but it seems that they only operate on a single object at a time. What I am trying to do is make sure that a set of saves happens correctly or rolls back...

Something like:

Code:
$this->db->trans_start();
$1->save();
$2 -> save();
$3 -> save();
$4 -> save();
$5 -> save();
$this->db->trans_complete();

Is this possible? Or is there some other way to do this?

Thx


[eluser]WanWizard[/eluser]
Transactions in Datamapper are indeed object based.

If you want to encapsulate multiple Datamapper operations, your suggestion is the way to go.

You have to check though how your database connections (dbparms) are configured, because you need all objects to re-use $this-db, and not have their own connection to the database. By default though, $this->db is re-used.

[eluser]Unknown[/eluser]
Quick question.

How would I write the model relation for this. Slightly confused about the Self relation, i.e menu item and sub menu

Menu has many submenus and submenus can have one or more sub-submenus

Class: navigation
Table: Navigation
[id] [parent_id] [Name] ..

Thanks

[eluser]WanWizard[/eluser]
@ebsol,

Self relations aren't the most efficient solution to store tree structures in the database, it is every complex to use DM to iterate over your menu items. I suggest you have a look at the nested sets extension instead.

[eluser]Unknown[/eluser]
I am creating a model object like this:
Code:
$object1 = new Object1();
There is a table in the database named object1s. The Object1 class is an empty class that extends DataMapper. That works without problems. I am able to save data, and retrieve data from the database.

I tried to same thing with another object (and a different table), for example,
Code:
$object2 = new Object2();
This time I get the error message:

Code:
Fatal error: Call to a member function line() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/c/application/libraries/Datamapper.php on line 6049

Line 6049 does this:
Code:
return $this->lang->line($key);

The first object has an instance of DM_Lang in $this->lang at this point, but the second object has the string "en".

What can I do to fix this? Why are they different? Where are they being set?

Thank you for your help.

[eluser]WanWizard[/eluser]
I assume that something in your model overwrites $this->lang. Probably because you have a column called 'lang'.

See http://datamapper.wanwizard.eu/pages/reservednames.html for a list of reserved names. These can not be used for either class properties or column names, either because Datamapper uses them, or because they're used by CI (like this case).




Theme © iAndrew 2016 - Forum software by © MyBB