• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Datamapper ORM - Deep Relationship with AES_encrypted fields in mySQL

Hi All,

If I've got the following setup...

Users (aes encrypted fields)
Document Revisions

A Document can have many Document Revisions
A Document Revision has one user that uploaded it (stored as user_id)

I need to encrypt the fields in the users table using aes_encrypt and decode them using aes_decrypt via mySQL. Which works fine for the user model as I can add in the select query to do the decode functions.

But what if I want to return the deep relationship, from the Document object, and decrypt the users firstname, lastname and emailaddress fields.

$document = new Document;
$revisions = $document->document_revision->order_by('revision_number','desc')->get();

I'm currently doing the above, and then doing a foreach in the view... (I've removed the HTML inbetween the PHP tags for this demo.
foreach ($revisions as $k=>$revision){
                    <?Php echo $revision->revision_number;?>              
                    <?php echo $revision->notes;?>
                    <?php echo date('H:ia jS F Y',strtotime($revision->created));?>
                    <?php echo $revision->user->firstname." ".$revision->user->lastname;?>

So how do I get my user->firstname response to produce the decrypted aes field instead of the raw string from the DB which is a bunch of characters.



Messages In This Thread
Datamapper ORM - Deep Relationship with AES_encrypted fields in mySQL - by El Forum - 12-31-2011, 04:43 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.