| 442 | } |
| 443 | |
| 444 | HistoryItem CHistoryDatabase::getHistoryById(int id) |
| 445 | { |
| 446 | HistoryItem item; |
| 447 | |
| 448 | QSqlQuery query(GetDatabase()); |
| 449 | query.prepare( |
| 450 | "SELECT id, url, visit_time " |
| 451 | "FROM history WHERE id = :id" |
| 452 | ); |
| 453 | query.bindValue(":id", id); |
| 454 | |
| 455 | if (query.exec()) { |
| 456 | if(query.next()) { |
| 457 | item.id = query.value(0).toInt(); |
| 458 | int urlId = query.value(1).toInt(); |
| 459 | auto urlItem = m_UrlDB.GetItem(urlId); |
| 460 | item.url = urlItem.szUrl; |
| 461 | item.title = urlItem.szTitle; |
| 462 | item.icon = urlItem.icon; |
| 463 | item.visitTime = query.value(2).toDateTime(); |
| 464 | } |
| 465 | } else { |
| 466 | QString szErr = "Failed to get history by id:" + query.lastError().text() |
| 467 | + "; Sql: " + query.executedQuery() |
| 468 | + "; id: " + QString::number(id); |
| 469 | SetError(szErr); |
| 470 | qCritical(log) << GetError(); |
| 471 | } |
| 472 | |
| 473 | return item; |
| 474 | } |
| 475 | |
| 476 | int CHistoryDatabase::getHistoryCount() |
| 477 | { |