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

#1
[eluser]Unknown[/eluser]
Hi All,

If I've got the following setup...

Users (aes encrypted fields)
Documents
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.

Code:
$document = new Document;
$document->get_by_id($id);
        
$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.
Code:
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.

Thanks,

Jason


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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