Mercurial > hg > orthanc-databases
comparison Framework/MySQL/MySQLDatabase.cpp @ 186:6fe74f9a516e
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Dec 2020 15:05:19 +0100 |
parents | 0632c2408af3 |
children | 0b78198c28d6 |
comparison
equal
deleted
inserted
replaced
185:7c46155b5bb4 | 186:6fe74f9a516e |
---|---|
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 query.SetType("lock", ValueType_Utf8String); | 327 query.SetType("lock", ValueType_Utf8String); |
328 | 328 |
329 MySQLStatement statement(*this, query); | |
330 | |
331 Dictionary args; | 329 Dictionary args; |
332 args.SetUtf8Value("lock", prefix + "." + lock); | 330 args.SetUtf8Value("lock", prefix + "." + lock); |
333 | 331 |
334 bool success; | 332 bool success; |
335 | 333 |
336 { | 334 { |
335 MySQLStatement statement(*this, query); | |
336 | |
337 MySQLTransaction t(*this); | 337 MySQLTransaction t(*this); |
338 std::unique_ptr<IResult> result(t.Execute(statement, args)); | 338 std::unique_ptr<IResult> result(t.Execute(statement, args)); |
339 | 339 |
340 success = (!result->IsDone() && | 340 success = (!result->IsDone() && |
341 result->GetField(0).GetType() == ValueType_Integer64 && | 341 result->GetField(0).GetType() == ValueType_Integer64 && |
458 | 458 |
459 std::unique_ptr<IResult> result(statement.Execute(transaction, args)); | 459 std::unique_ptr<IResult> result(statement.Execute(transaction, args)); |
460 return (!result->IsDone() && | 460 return (!result->IsDone() && |
461 result->GetFieldsCount() == 1 && | 461 result->GetFieldsCount() == 1 && |
462 result->GetField(0).GetType() == ValueType_Integer64 && | 462 result->GetField(0).GetType() == ValueType_Integer64 && |
463 dynamic_cast<const Integer64Value&>(result->GetField(0)).GetValue() == 1); | 463 dynamic_cast<const Integer64Value&>(result->GetField(0)).GetValue() != 0); |
464 } | 464 } |
465 | 465 |
466 | 466 |
467 void MySQLDatabase::Execute(const std::string& sql, | 467 void MySQLDatabase::Execute(const std::string& sql, |
468 bool arobaseSeparator) | 468 bool arobaseSeparator) |
528 { | 528 { |
529 dynamic_cast<MySQLStatement&>(statement).ExecuteWithoutResult(*this, parameters); | 529 dynamic_cast<MySQLStatement&>(statement).ExecuteWithoutResult(*this, parameters); |
530 } | 530 } |
531 | 531 |
532 public: | 532 public: |
533 MySQLImplicitTransaction(MySQLDatabase& db) : | 533 explicit MySQLImplicitTransaction(MySQLDatabase& db) : |
534 db_(db) | 534 db_(db) |
535 { | 535 { |
536 } | 536 } |
537 }; | 537 }; |
538 } | 538 } |