Assigning mysql functions at field level

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Assigning mysql functions at field level

Post by GeXus »

Is it possible to assign a mysql function at the field level of a table? Say for example I wanted to encrypt all data that is inserted into a particular field with aes_encrypt(), instead of simply using this in the insert, it could be cool if you could just set it to always use that on any data inserted into that field...
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

This is where stored procedures come into play. Check it out on the mysql web site.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Triggers would by my preferred variant of solution. :)
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Ahh triggers seem perfect... now I can justify upgrading mysql.
Post Reply