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

[eluser]WanWizard[/eluser]
No, there isn't.

The ORM itself is already running for over two years, so it's code is very stable. But it depends on a specific DBAL, like Datamapper currently depends on CI's DB layer.

A new DBAL is being developed, and once that is ready, the ORM code will be refactored to use this new DBAL. All other dependencies will have to be addressed too.

I don't expect a version to be available for general use before the beginning of the summer.

[eluser]michaelfbradley[/eluser]
Hey - Really liking Datamapper.

I have two quick questions.

1. I was wondering if it's possible to define virtual attributes within the model?

Let's say for example I have a users model, and I want to explicitly define a virtual attribute called 'fullname', which uses the firstname and lastname fields from my DB?


2. Is it possible to define different validation requirements for various scenarios within the model? Let's say I have different validation requirements whenever when updating a record, versus creating a record.

Thanks,
M

[eluser]matyhaty[/eluser]
[quote author="michaelfbradley" date="1363610203"]Hey - Really liking Datamapper.

I have two quick questions.

1. I was wondering if it's possible to define virtual attributes within the model?

Let's say for example I have a users model, and I want to explicitly define a virtual attribute called 'fullname', which uses the firstname and lastname fields from my DB?


2. Is it possible to define different validation requirements for various scenarios within the model? Let's say I have different validation requirements whenever when updating a record, versus creating a record.

Thanks,
M[/quote]

Hi

I'm not aware of any virtual options but layout of code might help here. Also are you using the array extension. If not, do.

So an example update/create prototype

Function edit($id = null)
{
If($id)
{ // your validation options for an edit }
Else
{ // validation options for a new entry }

// for virtual options lets say your form
// has firstname and surname
// but you store in your db 'fullname'

$data = $_post;
$data['fullname'] = $data[firstname] + $data[lastname]

// save entry.
$user = new User($id);
$user->save-from-array($data)(

// I'm pretty sure that save from array finction name is wrong
// check docs (I'm writting this on an iPhone!!!)

}

[eluser]WanWizard[/eluser]
No, Datamapper doesn't have any viral capabilities. Altough you could use get_rules to create these fields after reading a record, or rules before saving it.

As to validation, I think it's bad design if your rules differ from insert to update. Rules are there to make sure data in your database is validated. A rule on a column value should be consistent, it doesn't matter if it's an insert or an update.

[eluser]spectro200[/eluser]
Hi, i’m new in this comunity. Sorry but i’m spanish and my english is bad…

i have a problem when i test the example, when i create the database i receive and error that said:


Unable to load the requested file: dmz_htmlform/section.php


The error appear when the example run in controller admin,method init——> ../admin/init.php

thanks!

[eluser]Stolz[/eluser]
[quote author="spectro200" date="1363613792"]Hi, i’m new in this comunity. Sorry but i’m spanish and my english is bad…

i have a problem when i test the example, when i create the database i receive and error that said:


Unable to load the requested file: dmz_htmlform/section.php


The error appear when the example run in controller admin,method init——> ../admin/init.php

thanks![/quote]

[English]
That error means the required views for the htmlform extension are missing. You are supposed to copy the folder dmz_htmlform/ from the DM zip file into your application/views/ folder. If you don't plan to use the htmlform extension (which is currently unsupported) then you don't need to do it.

[Spanish]
El error es porque se te ha olvidado copiar el directorio dmz_htmlform/ del zip de DM al directorio application/views/. Si no tienes pensado usar la extensión htmnlforms (que por cierto ha dejado de estar soportada) entonces no te hace falta copiar nada.

[eluser]spectro200[/eluser]
[quote author="Stolz" date="1363629757"][quote author="spectro200" date="1363613792"]Hi, i’m new in this comunity. Sorry but i’m spanish and my english is bad…

i have a problem when i test the example, when i create the database i receive and error that said:


Unable to load the requested file: dmz_htmlform/section.php


The error appear when the example run in controller admin,method init——> ../admin/init.php

thanks![/quote]

[English]
That error means the required views for the htmlform extension are missing. You are supposed to copy the folder dmz_htmlform/ from the DM zip file into your application/views/ folder. If you don't plan to use the htmlform extension (which is currently unsupported) then you don't need to do it.

[Spanish]
El error es porque se te ha olvidado copiar el directorio dmz_htmlform/ del zip de DM al directorio application/views/. Si no tienes pensado usar la extensión htmnlforms (que por cierto ha dejado de estar soportada) entonces no te hace falta copiar nada.[/quote]

[English]
thanks for the reply, I'm not interested in using the package, just want to see how the example. But if I do not use it and I have the example references to that package, would have to tweak all code no?

[Spanish]
gracias por la respuesta, no estoy interesado en usar el paquete, simplemente quiero ver como funciona el ejemplo. Pero si no quiero usarlo y tengo en el ejemplo referencias a ese paquete, tendria que retocar todo el codigo no?


PD: I'm using DataMapper 1.8.2.1
PD: Estoy usando DataMapper 1.8.2.1

[eluser]matyhaty[/eluser]
Spectro

As its not supported, and your learning, you do not want to use it - for sure

Focus on the Array extension - which you will great much better mileage out of

Also - you could always use the ignited forms website to make your form code for you.....

Regards

[eluser]spectro200[/eluser]
Ok thanks Smile

[eluser]Bard[/eluser]
Hi,
I'm creating a simple shopping script with codeigniter & datamapper.

class Product extends DataMapper {
public $table = 'products';
var $has_one = array('user');
var $has_many = array('order');


class Order extends DataMapper {
public $table = 'orders';
var $has_many = array('product');

everything works fine with a joining table (orders_products), but i'm a little confused;

id,order_id,product_id seems fine when you buy from each product by one.
but when i buy 2 piece of product 1 and 1 piece of product 2, i can set only 2 pieces relation. how can i set counts for each product in orders?




Theme © iAndrew 2016 - Forum software by © MyBB