æ¦è¦
Perl ã® DBI ããåãããªãã¦ãã¤ããæ°æã¡ã«ãªã£ãã®ã§ãåå¼·ã®ããã«æä½éã®æ©è½ã ãããã·ã³ãã«ãªO/Rãããã¼ãä½ã£ã¦ã¿ããã¨ããããããã RDBMS å¼±ãããã SQL å ¨ç¶åãããªããå³ããã
ã¾ãã¯ãµã¼ãã¹ã¨ã¢ãã«ãå®ç¾©ããã
package Service::User; use parent, "Mos::User"; package Model::User; use parent, "Mos::Model"; use Mos::Model; column("id", "int"); column("name", "string"); column("age", "int"); timestamp;
ããããã¨ãããªæãã§ä½¿ããã
Service::User->create({name => "sixeight", age => 28}); Service::User->create({name => "tomohi_ro", age => 29}); my $users = Service::User->all({order_by => "id DESC"}); for my $user (@$users) { say "id: " . $user->id; say "name: " . $user->name; say "age: " . $user->age; say "created_at: " . $user->created_at; } my $user = $users->[0]; $user->age(30); Service::User->update($user); my $adult = Service::User->find({age => 30}); say $adult->name; say $adult->updated_at;
ä¸æº
ã¢ãã«ã®å®ç¾©ã« user parent
㨠user Mos::Model
ãå¿
è¦ãç¶æ¿ãã¦ãããã¨ãæ示ãã¤ã¤ import
ãå¼ã³ããã£ãããä½æ³ãåãããªãã
column
ã§åã渡ãã®ãæååãªã®ãã ããã
find
ã§æè»ãªæ¤ç´¢ãã§ããªãã29æ以ä¸ã¨ãããããã®ã
ã¨ã©ã¼å¦çãé©å½ã
ãã©ã³ã¶ã¯ã·ã§ã³ã«å¯¾å¿ãã¦ãªãã®ã§ãService::User->dbh->begin_work
ã¨ãæ¸ãå¿
è¦ãããã
ãªãä½ãã®ã
é ãæªãã®ã§ããããªæ©è½ãã¤ãã¦ããæ¢åã®ããããã¤ã使ãããªããªãããèªãã§ãç解ããã®ã«æéããããã èªåã§ä½ã£ããä»çµã¿ãåããããèªåã®å¥½ããªããã«åºæ¥ãã®ã§å¿ è¦ãªæ©è½ã ãå ¥ãã¦ã·ã³ãã«ã«ä¿ã¦ãã好ãã«åºæ¥ãã®ã¯ãããå ¨è½æã
æ¬ ç¹
è»è¼ªã®åçºæãã¡ã³ããã³ã¹åºæ¥ãªãã
ååã®ç±æ¥
ã¢ã¹ã«ãã§ã§æ¸ããããã
ææ³
Ruby ã«æ¯ã¹ã¦ Perl ã¯é»éè¡ãã«ãããRuby ãªãä¸ç¬ã§æ¸ããããªã®ã妥åããããå¾ãªãã£ããããã ã§ãããªããæä½ãæããã£ã¦æ¥½ããæ°ãããããããªã«æ¥½ãããªãã大å¦çãããã®ããã«ãã£ã¨ã¡ããã¨ãã£ã¦ããã°è¯ãã£ãã¨æãã
ãã¾ã¯è¦ããªãã¦ã¯ãããªãè¨èªã沢山ãã£ã¦ãããçæ´»ãããã£ã¦ããã®ã¯ãªãã£ã«ã«ãPerl ã§æ¶èãã¦ããå ´åã§ã¯ãªãã®ã ããã©ãPerl ãã£ã¦ããªãã£ãåã®ãã£ãºè¿ããæ¥ã¦ããã
ã¾ã¨ã
ãã®æç« ã¯é ã£æã£ã¦æ¸ãã¦ãããä½ãæ¸ãããããåãã£ã¦ããªãã
ææ¥åçãããã¤ã
ç¶ã»åãã¦ã®Perl æ¹è¨ç¬¬2ç
- ä½è : Randal L. Schwartz,brian d foy,Tom Phoenix,ä¼è¤ç´ä¹(ç£è¨³),é·å°¾é«å¼
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³
- çºå£²æ¥: 2013/08/21
- ã¡ãã£ã¢: 大åæ¬
- ãã®ååãå«ãããã° (2件) ãè¦ã