mysql> select id, nom, slug from auteur; +----+-----------+---------------+ | id | nom | slug | +----+-----------+---------------+ | 1 | Dick | | | 2 | Dick | | | 3 | Abbott | | | 4 | Pratchett | | | 5 | Richard | | | 6 | Pouy | | | 7 | McFadyen | Cody_McFadyen | +----+-----------+---------------+ 7 rows in set (0.00 sec)
$ PERL5LIB=./models perconsole
Perl> use Auteur; use Utils
Perl> my @auteur = Auteur->find()
$ARRAY1 = [
Auteur=HASH(0x877e084),
Auteur=HASH(0x8b83e9c),
Auteur=HASH(0x8b838a8),
Auteur=HASH(0x8b83eb4),
Auteur=HASH(0x8b861b8),
Auteur=HASH(0x8b86194),
Auteur=HASH(0x8b83f98)
];
Perl> foreach my $a (@auteur) {
$a->slug(to_slug($a->prenom.' '.$a->nom));
$a->save;
}
mysql> select id, nom, slug from auteur; +----+-----------+---------------------+ | id | nom | slug | +----+-----------+---------------------+ | 1 | Dick | Philip_Kindred_Dick | | 2 | Dick | Philip_K_Dick | | 3 | Abbott | Jeff_Abbott | | 4 | Pratchett | Terry_Pratchett | | 5 | Richard | Jennifer_D_Richard | | 6 | Pouy | Jean_Bernard_Pouy | | 7 | McFadyen | Cody_McFadyen | +----+-----------+---------------------+ 7 rows in set (0.00 sec)
Putain je kiffe vraiment trop ! :-)