[Phpwm] MySQL triggers, creating hashed id

francis ihebom fihebom at googlemail.com
Sat Aug 18 17:48:03 BST 2007


hello Eliot,
I belivee you are the Person i spoke to last week from Joniva in digbeth,
concerning www.2ndcityacademy.co.uk
we transfered our hosting company from LCN to 1and1 but we are unable to
remove LCN's databse Tag .please could you advice us ?
i appreciate.
Francis

On 8/17/07, pete graham <petegraham1 at gmail.com> wrote:
>
> Regarding my last problem I have decided to store items in my database
> with a hash of each items id. Ideally I'd like to do this using
> triggers to keep everything nice and clean. However I'm feeling quite
> dumb today and can't work out how to do it. Here's my attempt:
>
> CREATE TRIGGER clips_create_hash BEFORE INSERT ON `clips` FOR EACH ROW SET
> NEW.id_hash = sha1(NEW.id);
>
> This ends up setting all the hashes the same, I believe that it's
> getting 0 for the value of NEW.id. This makes sense since id is a
> auto-incrementing primary key so wouldn't exist before the insert. But
> if I try to change the trigger to make it 'AFTER' I get this:
>
> "Updating of NEW row is not allowed in after trigger"
>
> Any help greatly appreciated.
>
> Thanks, Pete
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>


More information about the Phpwm mailing list