I would make another class mapped to the sane table. Maybe called karma_info
and maybe make it a base class for user, but only having those two fields.
On 25/12/2010 10:45 AM, "yufeng" <[email protected]> wrote:
> hi:
> "session.find<User>;" query all field of table,but sometimes I want to
> query only some field not all,How to implement it?I reference
> session.find,I use session.query
> (tutorial1.C continued)
> typedef dbo::collection< dbo::ptr<User> > Users;
>
> Users users = session.find<User>();
>
> std::cerr << "We have " << users.size() << " users:" << std::endl;
>
> for (Users::const_iterator i = users.begin(); i != users.end(); ++i)
> std::cerr << " user " << (*i)->name
> << " with karma of " << (*i)->karma << std::endl;
> here is my code :
> typedef Wt::Dbo::ptr<XDBBlog> XDBBlogPtr;
> typedef Wt::Dbo::collection<Wt::Dbo::ptr<XDBBlog> > XDBBlogs;
> Wt::Dbo::Transaction dbTran(*mpWebApp->mpDBSession);
> XDBBlogs aDBBlogs = mpWebApp->mpDBSession->query<XDBBlogPtr>("SELECT
fuid,ftitle,fdate,freader,frun FROM tblog").where("fshow=1 AND
fshare=1").limit(miPageRows).orderBy("frun DESC,fuid
ASC").offset(offset_page);
> for (XDBBlogs::const_iterator ii = aDBBlogs.begin(); ii != aDBBlogs.end();
++ii)
> {
> sUid=boost::lexical_cast<string>((*ii)->mUid);
> //稿件标题
> sVal="#/"+msID+"/show/"+sUid;
> pAnchor=new WAnchor(sVal,WString::fromUTF8((*ii)->mTitle),pDiv);
> pAnchor->setTarget(TargetNewWindow);
> pAnchor ->setId("title");
> }
> dbTran.commit();
> when run , [fatal] "Session::query(): too many aliases for result"
> error occur
>
>
>
------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment,
and,
> should the need arise, upgrade to a full multi-node Oracle RAC database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest