本文整理汇总了C++中TSqlORMapper类的典型用法代码示例。如果您正苦于以下问题:C++ TSqlORMapper类的具体用法?C++ TSqlORMapper怎么用?C++ TSqlORMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TSqlORMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gc
int TSessionSqlObjectStore::gc(const QDateTime &expire)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::UpdatedAt, TSql::LessThan, expire);
int cnt = mapper.removeAll(cri);
return cnt;
}
示例2: store
bool TSessionSqlObjectStore::store(TSession &session)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
TSessionObject so = mapper.findFirst(cri);
#ifndef TF_NO_DEBUG
{
QByteArray badummy;
QDataStream dsdmy(&badummy, QIODevice::ReadWrite);
dsdmy << *static_cast<const QVariantMap *>(&session);
TSession dummy;
dsdmy.device()->seek(0);
dsdmy >> *static_cast<QVariantMap *>(&dummy);
if (dsdmy.status() != QDataStream::Ok) {
tSystemError("Failed to store a session into the cookie store. Must set objects that can be serialized.");
}
}
#endif
QDataStream ds(&so.data, QIODevice::WriteOnly);
ds << *static_cast<const QVariantMap *>(&session);
if (ds.status() != QDataStream::Ok) {
tSystemError("Failed to store session. Must set objects that can be serialized.");
return false;
}
if (so.isNull()) {
so.id = session.id();
return so.create();
}
return so.update();
}
示例3: remove
bool TSessionSqlObjectStore::remove(const QDateTime &garbageExpiration)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::UpdatedAt, TSql::LessThan, garbageExpiration);
int cnt = mapper.removeAll(cri);
return (cnt >= 0);
}
示例4: get
RefPackingDef RefPackingDef::get(const QString &createdBy, const QString &updatedBy)
{
TCriteria cri;
cri.add(RefPackingDefObject::CreatedBy, createdBy);
cri.add(RefPackingDefObject::UpdatedBy, updatedBy);
TSqlORMapper<RefPackingDefObject> mapper;
return RefPackingDef(mapper.findFirst(cri));
}
示例5: get
Vehicles Vehicles::get(int id, int lockRevision)
{
TSqlORMapper<VehiclesObject> mapper;
TCriteria cri;
cri.add(VehiclesObject::Id, id);
cri.add(VehiclesObject::LockRevision, lockRevision);
return Vehicles(mapper.findFirst(cri));
}
示例6: get
ParkAttendants ParkAttendants::get(int id, int lockRevision)
{
TSqlORMapper<ParkAttendantsObject> mapper;
TCriteria cri;
cri.add(ParkAttendantsObject::Id, id);
cri.add(ParkAttendantsObject::LockRevision, lockRevision);
return ParkAttendants(mapper.findFirst(cri));
}
示例7: get
ChatLog ChatLog::get(int id, int lockRevision)
{
TSqlORMapper<ChatLogObject> mapper;
TCriteria cri;
cri.add(ChatLogObject::Id, id);
cri.add(ChatLogObject::LockRevision, lockRevision);
return ChatLog(mapper.findFirst(cri));
}
示例8: get
UserVehicle UserVehicle::get(int id, int lockRevision)
{
TSqlORMapper<UserVehicleObject> mapper;
TCriteria cri;
cri.add(UserVehicleObject::Id, id);
cri.add(UserVehicleObject::LockRevision, lockRevision);
return UserVehicle(mapper.findFirst(cri));
}
示例9: getAllJson
QJsonArray AccountsRecharge::getAllJson()
{
QJsonArray array;
TSqlORMapper<AccountsRechargeObject> mapper;
if (mapper.find() > 0) {
for (TSqlORMapperIterator<AccountsRechargeObject> i(mapper); i.hasNext(); ) {
array.append(QJsonValue(QJsonObject::fromVariantMap(AccountsRecharge(i.next()).toVariantMap())));
}
}
return array;
}
示例10: getAllJson
QJsonArray ParkAttendants::getAllJson()
{
QJsonArray array;
TSqlORMapper<ParkAttendantsObject> mapper;
if (mapper.find() > 0) {
for (TSqlORMapperIterator<ParkAttendantsObject> i(mapper); i.hasNext(); ) {
array.append(QJsonValue(QJsonObject::fromVariantMap(ParkAttendants(i.next()).toVariantMap())));
}
}
return array;
}
示例11: getAllJson
QJsonArray UserVehicle::getAllJson()
{
QJsonArray array;
TSqlORMapper<UserVehicleObject> mapper;
if (mapper.find() > 0) {
for (TSqlORMapperIterator<UserVehicleObject> i(mapper); i.hasNext(); ) {
array.append(QJsonValue(QJsonObject::fromVariantMap(UserVehicle(i.next()).toVariantMap())));
}
}
return array;
}
示例12: count
void ChatLog::removeOldLogs(int remainingCount)
{
int del = count() - remainingCount;
if (del > 0) {
TSqlORMapper<ChatLogObject> mapper;
mapper.setSortOrder(ChatLogObject::Id, Tf::DescendingOrder);
auto log = mapper.findFirst();
int maxId = log.id;
TCriteria ctr(ChatLogObject::Id, TSql::LessEqual, maxId - remainingCount);
mapper.removeAll(ctr);
}
}
示例13: store
bool TSessionSqlObjectStore::store(TSession &session)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
TSessionObject so = mapper.findFirst(cri);
QDataStream ds(&so.data, QIODevice::WriteOnly);
ds << *static_cast<const QVariantHash *>(&session);
if (so.isEmpty()) {
so.id = session.id();
return so.create();
}
return so.update();
}
示例14: find
TSession TSessionSqlObjectStore::find(const QByteArray &id, const QDateTime &modified)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri;
cri.add(TSessionObject::Id, TSql::Equal, id);
cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);
TSessionObject sess = mapper.findFirst(cri);
if (sess.isEmpty())
return TSession();
TSession result(id);
QDataStream ds(&sess.data, QIODevice::ReadOnly);
ds >> *static_cast<QVariantHash *>(&result);
return result;
}
示例15: find
TSession TSessionSqlObjectStore::find(const QByteArray &id)
{
QDateTime modified = QDateTime::currentDateTime().addSecs(-lifeTimeSecs());
TSqlORMapper<TSessionObject> mapper;
TCriteria cri;
cri.add(TSessionObject::Id, TSql::Equal, id);
cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);
TSessionObject so = mapper.findFirst(cri);
if (so.isNull()) {
return TSession();
}
TSession session(id);
QDataStream ds(&so.data, QIODevice::ReadOnly);
ds >> *static_cast<QVariantMap *>(&session);
if (ds.status() != QDataStream::Ok) {
tSystemError("Failed to load a session from the sqlobject store.");
}
return session;
}