25 August 2006
This post may be outdated due to it was written on 2006. The links may be broken. The code may be not working anymore. Leave comments if needed.
DBIx::Class 简单地读取一条数据的时候有三种方法。

一是用 ->search( { author_id => 1 } )->first;
二是用 ->find( { author_id => 1 } );
三是用 ->single( { author_id => 1 } );

我用 Data::Compare 比较过。三者的数据是一样的。
但是原理上来说,最下面的是最快的。因为没有创建一个 Cursor.

http://search.cpan.org/~jrobinson/DBIx-Class-0.07001/lib/DBIx/Class/ResultSet.pm#single


blog comments powered by Disqus