Hey Mike,
2010/2/22 Mike Teehan <[email protected]>:
> Hello everyone. Just trying to get my head around the new Wt::Dbo::Dbo
> class... Basically, this lets you move some of your code into the db object's
> class, right?
*
> Example:
> I have a getUserList() function that queries the db to find all the users
> (class User) who can log in. This function lives in the login code. Once I
> switch to deriving my User from Dbo::Dbo, I can then move getUserList()
> to be part of the User class, better sharing the functionality.
>
> If this is the case, it looks like I have a bit of refactoring to do.
Yes, that is what it is meant for, although the particular example
getUserList() sounds like it is a static method which will not have
access to the session(), it is only associated with a particular user.
The standard use case would be like :
Posts User::latestPosts(int count) const
{
if (session())
return session()->find<Post>
("where author_id = ? and state = ? "
"order by date desc "
"limit ?")
.bind(id())
.bind(Post::Published)
.bind(count);
else
return Posts();
}
Note that session() may be 0 for an object that is not yet associated
with a session.
Regards,
koen
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest