[CDBI] 2 Questions?

Matt S Trout dbix-class at trout.me.uk
Thu Sep 15 18:05:17 BST 2005

On Thu, Sep 15, 2005 at 10:51:46AM -0500, melo_am0 at sewanee.edu wrote:
> Hey guys-
> Two quick things. Firstly, is CDBI thread-safe or do I need to wrap locks
> around functions that call CDBI methods to prevent bad things (tm) from
> happening?

If your DBD's thread safe, CDBI should be thread safe. The DBD probably
isn't though ...

> Secondly, is there a safe way to have a constructor that's called each
> time CDBI instantiates an object? I have a trigger set on before_create
> and select, but sometimes a class's constructor is never called, and other
> times the constructor is called twice.

Overriding 'construct' may do the trick for you.

DBIx::Class gets round this by having a real 'new' method, which makes life
rather simpler (and also allows objects not in the db - create is just a
shortcut for ->new(...)->insert)

     Matt S Trout       Specialists in perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

More information about the ClassDBI mailing list