Questions update:
Is posible to execute a join without creating a join table?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 14, 2010 11:43pm
Subscribe [104]#826 / Jan 12, 2011 6:48am
Questions update:
Is posible to execute a join without creating a join table?
#827 / Jan 12, 2011 9:17am
Hello, thanks for the previous answer…
Please help me think about this one:
I have the model Client that can be a PERSON or a COMPANY. Not both at the same time…
Is there a validation rule to help me with that ?
If not, is there a better way to do this without a validation rule?
If not, can u help me build a validation rule for it ?
Thanks,,,,
#828 / Jan 12, 2011 9:22am
Questions update:
Is posible to execute a join without creating a join table?
Yes… if it is a HAS ONE relationship… u just need to add the field YOURRELATEDMODEL_id in the model table…
Example:
Lets say u have the model Owner and the model Dog and u need to relate those. Instead of creating a join table with: id, owner_id, dog_id, you can simple add the field dog_id in the owner table.
I hope u understood my answer and it is the answer u are looking for.
#829 / Jan 12, 2011 11:21am
@paulipv,
locatisation within Datamapper is used for validation, so that you can translate field names in messages. It is documented here: http://datamapper.wanwizard.eu/pages/localize.html
#830 / Jan 12, 2011 11:27am
@PoetaWD,
There are lots of ways to solve this issue, but it’s more application or database design related, and has nothing to do with Datamapper. Datamapper only comes in if you have it implemented in your database, and you need to code the queries for it.
You could add a ‘client_type’ to the Client table (assuming a person can’t suddenly become a company. You can make code that does this, and switches the client_type). You can use a relationship table and set a constraint on it (client_id must be unique for example), you can do a check in your code, you can write a validation method that does a check when you save, etc.
You can even make a multi-relations table, where client has a many-to-many to each of the other tables needing a link to client. And make client_id in that table unqiue.
None of these are Datamapper questions though…
#831 / Jan 12, 2011 5:24pm
DataMapper ORM v1.8.0 has been released.
Use this thread for discussions or questions about v1.8.0.
People using older versions are strongly advised to upgrade to the new version. As of now, DMZ 1.7.1. is no longer officially supported.
Version 1.8.0 is a drop-in replacement for DMZ 1.7.1. See the new thread for an overview of fixes, enhancements and new functionality.
I would like to take this opportunity to thank Overzealous for all the hard work he’s put into DMZ over the last few years, and for making the product what it is today. Kudos Overzealous!
#832 / Jan 14, 2011 7:24pm
I’d be interested in taking a look at the code if no one else has stepped forward. If you have a moment, could you send a copy of everything related in an archive file to .(JavaScript must be enabled to view this email address)?
Thanks
#833 / Jan 15, 2011 6:40am
Matt,
What do you mean by this? I’ve just released a new version, see http://ellislab.com/forums/viewthread/178045/
#834 / Jan 15, 2011 6:44am
Matt,
What do you mean by this? I’ve just released a new version, see http://ellislab.com/forums/viewthread/178045/
Posted prior to finding DataMapper. Thought this was another discontinued project with some code I might be able to use. Didn’t feel like paging through 20 some pages from the first post indicating it was discontinued either.
#835 / Feb 14, 2011 7:34am
Hello
I have problems with validating 2 password fields (“Password” and “Confirm password”).
The problem is caused by encryption library I’m using (phpass - one way encryption) and “matches” rule set for “Confirm password”:
'password' => array ('label' => 'Password', 'rules' => array('trim', 'required', 'max_length' => 25, 'encrypt')),
'confirm_password' => array ('label' => 'Confirm Password', 'rules' => array('trim', 'required', 'max_length' => 25, 'matches' => 'password', 'encrypt' )),On each _encrypt function call, we get different strings/encrypted passwords, so “matches” rule simply won’t work.
I know it’s possible to solve this by creating custom validation where we compare values of 2 password input fields, but I would like to know is there an elegant solution.
Thanks
#836 / Feb 14, 2011 9:59am
Do I understand it correctly that you have a one-way encryption function that generates a different result when encrypting the same string?
If so, wouldn’t it be better to use a randomizer, it would be as effective…
When using the same phpass configuration and salt value, the hash should be the same for both password fields.
I suggest you look at your implementation of phpass it this is not the case.
#837 / Feb 14, 2011 12:19pm
For higher security, it’s not a good idea to have predefined salt and use it for all passwords.
Phpass deals with random salts internally:
Phpass transparently generates random salts when a new password or passphrase is hashed, and it encodes the hash type, the salt, and the password stretching iteration count into the “hash encoding string” that it returns
So setting a salt is simply not a solution to me.
#838 / Feb 14, 2011 6:52pm
I never said you should use a predefined salt, I said you should use the same salt value on both encrypt calls.
And it that’s no option, do the comparison in your own ‘matches’ method, or in your encrypt method before you hash it.
Just don’t call it a Datamapper issue, which it isn’t.
#839 / Feb 14, 2011 6:57pm
Where I said it’s a Datamapper issue? 😊
Thanks anyway, I’ll go with custom validation rule for both password fields.
#840 / Feb 20, 2011 2:15am
Hi
I’m trying to make a loop inside a loop, and i kind of made it work, but i feel like there has to be a better way to do this, because i can do the same thing without the ORM.
function test()
{
$c = new Chain();
$c->get();
foreach($c as $chain)
{
echo "<h3>".$chain->nme."</h3><p>";<br />
$r = new Restaurant();<br />
$r->where('chain_id', $chain->id)->get();<br />
foreach($r as $rest)<br />
{<br />
echo $rest->name."<br />
";<br />
}<br />
}<br />
}