MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / Update

Method Update

Src/Database/DatabaseTree.cpp:673–708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673bool CDatabaseTree::Update(const TreeItem &item)
674{
675 // Check if it is a leaf
676 if(item.IsNode()) {
677 qCritical(log) << "The item is not leaf";
678 return false;
679 }
680
681 QSqlQuery query(GetDatabase());
682 query.prepare(
683 "UPDATE `" + m_szTableName + "` SET "
684 "`name` = :name, "
685 "`key` = :key, "
686 "`created_time` = :created_time, "
687 "`modified_time` = :modified_time, "
688 "`last_visit_time` = :last_visit_time, "
689 "`parent_id` = :parent_id "
690 "WHERE `id` = :id"
691 );
692 query.bindValue(":name", item.GetName());
693 query.bindValue(":key", item.GetKey());
694 query.bindValue(":created_time", item.GetCreateTime());
695 query.bindValue(":modified_time", QDateTime::currentDateTime());
696 query.bindValue(":last_visit_time", item.GetLastVisitTime());
697 query.bindValue(":parent_id", item.GetParentId());
698 query.bindValue(":id", item.GetId());
699 qDebug(log) << "Sql:" << query.executedQuery();
700 qDebug(log) << "Bound value:" << query.boundValues();
701 bool bRet = query.exec();
702 if (!bRet) {
703 SetError("Failed to update tree item: " + query.lastError().text()
704 + "; Sql: " + query.executedQuery());
705 qCritical(log) << GetError();
706 }
707 return bRet;
708}
709
710bool CDatabaseTree::Delete(int id, bool delKey)
711{

Callers 1

updateBookmarkMethod · 0.80

Calls 7

IsNodeMethod · 0.80
GetKeyMethod · 0.80
GetLastVisitTimeMethod · 0.80
GetParentIdMethod · 0.80
GetNameMethod · 0.45
GetCreateTimeMethod · 0.45
GetIdMethod · 0.45

Tested by

no test coverage detected