Re: create without commit
[prev]
[thread]
[next]
[Date index for 2005/03/19]
On 19 Mar 2005, at 02:21, Tim McIntyre wrote:
> Hey all
>
> Is there an accepted way to create a cdbi object and not have it
> commit to the db?
>
> my $artist = Music::Artist->create({});
>
> Then have no entry in the db.
I use a 'ghost' class for this: a general purpose data holder that
mimics the behaviour of a designated cdbi class in simple but useful
ways and has make() and find_or_make methods() that turn it into a real
cdbi object. There's a version of this approach in
Class::DBI::Factory::Ghost, which could easily have its reliance on the
factory removed. I normally use it to hold either the precursor of an
object to be created or the echo of an object just deleted, so that
it's easy to display them on templates.
However, after many previous discussions of this topic I think it's
fair to say that most people regard this approach as evidence of Poor
Structure and Bad Thinking. see eg:
http://www.spanner.org/lists/cdbi/2004/10/15/7fd1521c.html
http://www.spanner.org/lists/cdbi/2004/10/19/a710a258.html
best
will
|
|
Re: create without commit
William Ross 14:05 on 19 Mar 2005
|