Welcome Guest, Not a member yet? Register   Sign In
DataMapper 1.6.0

[eluser]PoetaWD[/eluser]
[quote author="OverZealous.com" date="1246344561"]I'm pretty sure it's a bug in DMZ. I'm doing some tests now, to see what's going on. It might take me a few minutes.

Update: Yes, it is a bug. I've got a fix in place, and will have an updated version of DMZ for download in about 10 minutes. Thanks for finding this PoetaWD - it's a very serious bug, but luckily had an easy fix![/quote]

I am VERY happy that I helped... dont rush ... we want it flawless !

DMZ rox !

Thanks man !

[eluser]OverZealous[/eluser]
I just realized what forum we are on. PoetaWD - moving to the DMZ forum, because this is a problem that is unique to DMZ.

[eluser]PoetaWD[/eluser]
[quote author="OverZealous.com" date="1246347155"]I just realized what forum we are on. PoetaWD - moving to the DMZ forum, because this is a problem that is unique to DMZ.[/quote],

Ow..

That is true !

Sorry for that! I will start posting there instead !

Thanks

[eluser]gshipley[/eluser]
Thanks again for the great ORM.

Sorry if this is covered in the docs but I swear I couldn't find it. If it is, please just point me to the correct location in the doc.

Question: get_by_related

$u->get_by_related('group', 'name', 'Moderator');

What is I wanted to get_by_related where moderator is like 'rat'


$u->get_by_related('group', 'name', '%rat%';

Is that supported? (I think the exact syntax above doesn't work but is there a function call I am missing?)

[eluser]OverZealous[/eluser]
The get_by methods are just utility methods.

You can't do more complicated queries in one call, but it is easy to chain the methods like this:

Code:
// like CI's ActiveRecord, the '%' are automatically added to the query.  See the Get page of the manual
$u->like_related('group', 'name', 'rat')->get();

[eluser]gshipley[/eluser]
[quote author="OverZealous.com" date="1246480969"]The get_by methods are just utility methods.

You can't do more complicated queries in one call, but it is easy to chain the methods like this:

Code:
// like CI's ActiveRecord, the '%' are automatically added to the query.  See the Get page of the manual
$u->like_related('group', 'name', 'rat')->get();
[/quote]

Perfect! thank you so much.

[eluser][x26]VOLAND[/eluser]
Can I create several validation rule groups besides "var $validation = array(...);" ?

[eluser]ntheorist[/eluser]
the quick and dirty way to skip validation:

Code:
$user = new User();
$user->last_login = time();
$user->validated = TRUE; // fool into thinking its been validated
$user->valid = TRUE; // set as valid
$user->save();

You could write entire new validation arrays and overwrite it, then run validate(), but Datamapper stores the validation array in a static variable for any new instance of that model. You'd have to hack the constructor to allow for more.

better might be to build on top of DM, perhaps an extending class for your models, where you'd have your normal validation array, except each field could have a 'group' => $groupname var in it. (this would always either be specified, or set to a default group), then create a function such as validate_group($groupname)

the point tho, as above, it all comes down to setting $this->validated and $this->valid to TRUE, but you really don't want to skip validation altogether you'll end up with a mess/overwriting data etc.

[eluser]OverZealous[/eluser]
[quote author="[x26]VOLAND" date="1246588630"]Can I create several validation rule groups besides "var $validation = array(...);" ?[/quote]

I'm unsure what you are asking here. DataMapper only supports one set of validation rules.

There are two ways you can change the validation rules on-the-fly, however:

1) If you need a simple change based on an obvious factor, write your own validation rule. This rule could then check to see if it needs to be checked, and process the rule appropriately.

2) If you need massive validation changes, you can actually just replace $object->validation on the object you want to validate, and that will be used. Alternatively, you could replace a part of $validation, but this will affect all models of that type for that HTTP request, because they share a single validation array.

[eluser]ntheorist[/eluser]
it sounds like he wants to employ two uses of a single model. With the typical user model this would mean he prolly wants to be able to bypass creating a login (required for user) to store just an identity or for tracking. One idea would be to create a base Person model that 'User' extends, with little or no validation, or another way may be to create an extending model using a self join and give that a name with its own validation, ie:

Code:
class Temp_User extends User {

     $model = 'temp_user';
     $table = 'users';

     $validation = array(
          // only validate lastlogin etc
     }

     function Temp_User()
     {
          parent::User();
     }

}

in the case with the user model, you'd want to have some way to prevent empty logins. If you have your login() function in the User model, you overwrite it in Temp_User.

n




Theme © iAndrew 2016 - Forum software by © MyBB