Ticket #6591: mythplugins-6591-check_return_value_of_MSqlQuery_exec.patch
File mythplugins-6591-check_return_value_of_MSqlQuery_exec.patch, 50.7 KB (added by , 12 years ago) |
---|
-
mytharchive/mytharchive/videoselector.cpp
old new 397 397 CategoryMap categoryMap; 398 398 MSqlQuery query(MSqlQuery::InitCon()); 399 399 query.prepare("SELECT intid, category FROM videocategory"); 400 query.exec(); 401 if (query.isActive() && query.size()) 400 if (query.exec()) 402 401 { 403 402 while (query.next()) 404 403 { … … 413 412 query.prepare("SELECT intid, title, plot, length, filename, coverfile, " 414 413 "category, showlevel " 415 414 "FROM videometadata ORDER BY title"); 416 query.exec(); 417 if (query.isActive() && query.size()) 415 if (query.exec() && query.size()) 418 416 { 419 417 QString artist, genre; 420 418 while (query.next()) -
mytharchive/mytharchive/archiveutil.cpp
old new 135 135 "WHERE basename = :BASENAME"); 136 136 query.bindValue(":BASENAME", baseName); 137 137 138 query.exec(); 139 if (query.isActive() && query.size()) 138 if (query.exec() && query.next()) 140 139 { 141 query.first();142 140 chanID = query.value(0).toString(); 143 141 startTime= query.value(1).toString(); 144 142 } -
mytharchive/mytharchive/mythburn.cpp
old new 495 495 MSqlQuery query(MSqlQuery::InitCon()); 496 496 query.prepare("SELECT title FROM recorded WHERE basename = :FILENAME"); 497 497 query.bindValue(":FILENAME", baseName); 498 query.exec(); 499 if (query.isActive() && query.size()) 498 if (query.exec() && query.size()) 500 499 return true; 501 500 else 502 501 { … … 511 510 query.prepare("SELECT title FROM videometadata" 512 511 " WHERE filename = :FILENAME"); 513 512 query.bindValue(":FILENAME", filename); 514 query.exec(); 515 if (query.isActive() && query.size()) 513 if (query.exec() && query.size()) 516 514 return true; 517 515 else 518 516 { … … 739 737 // remove all old archive items from DB 740 738 MSqlQuery query(MSqlQuery::InitCon()); 741 739 query.prepare("DELETE FROM archiveitems;"); 742 query.exec(); 740 if (!query.exec()) 741 MythDB::DBError("MythBurn::saveConfiguration - deleting archiveitems", 742 query); 743 743 744 744 // save new list of archive items to DB 745 745 ArchiveItem *a; … … 992 992 { 993 993 MSqlQuery query(MSqlQuery::InitCon()); 994 994 query.prepare("SELECT title FROM videometadata"); 995 query.exec(); 996 if (query.isActive() && query.size()) 995 if (query.exec() && query.size()) 997 996 { 998 997 } 999 998 else -
mytharchive/mytharchive/exportnative.cpp
old new 286 286 "startdate, starttime, filename, hascutlist " 287 287 "FROM archiveitems WHERE type = 'Recording' OR type = 'Video' " 288 288 "ORDER BY title, subtitle"); 289 query.exec(); 290 if (query.isActive() && query.size()) 289 if (query.exec()) 291 290 { 292 291 while (query.next()) 293 292 { … … 330 329 // remove all old archive items from DB 331 330 MSqlQuery query(MSqlQuery::InitCon()); 332 331 query.prepare("DELETE FROM archiveitems;"); 333 query.exec(); 332 if (!query.exec()) 333 MythDB::DBError("ExportNative::saveConfiguration - " 334 "deleting archiveitems", query); 334 335 335 336 // save new list of archive items to DB 336 337 ArchiveItem *a; … … 394 395 MSqlQuery query(MSqlQuery::InitCon()); 395 396 query.prepare("DELETE FROM archiveitems WHERE filename = :FILENAME;"); 396 397 query.bindValue(":FILENAME", curItem->filename); 397 query.exec(); 398 if (query.isActive() && query.numRowsAffected()) 398 if (query.exec() && query.numRowsAffected()) 399 399 { 400 400 getArchiveList(); 401 401 } … … 508 508 { 509 509 MSqlQuery query(MSqlQuery::InitCon()); 510 510 query.prepare("SELECT title FROM videometadata"); 511 query.exec(); 512 if (query.isActive() && query.size()) 511 if (query.exec() && query.size()) 513 512 { 514 513 } 515 514 else -
mytharchive/mytharchive/importnative.cpp
old new 482 482 query.bindValue(":NAME", name); 483 483 query.bindValue(":CALLSIGN", callsign); 484 484 485 query.exec(); 486 if (query.isActive() && query.size()) 485 if (query.exec() && query.next()) 487 486 { 488 487 // got match 489 query.first();490 488 m_localChanID_text->SetText(query.value(0).toString()); 491 489 m_localChanNo_text->SetText(query.value(1).toString()); 492 490 m_localChanName_text->SetText(query.value(2).toString()); … … 499 497 "WHERE callsign = :CALLSIGN;"); 500 498 query.bindValue(":CALLSIGN", callsign); 501 499 502 query.exec(); 503 if (query.isActive() && query.size()) 500 if (query.exec() && query.next()) 504 501 { 505 502 // got match 506 query.first();507 503 m_localChanID_text->SetText(query.value(0).toString()); 508 504 m_localChanNo_text->SetText(query.value(1).toString()); 509 505 m_localChanName_text->SetText(query.value(2).toString()); … … 516 512 "WHERE name = :NAME;"); 517 513 query.bindValue(":NAME", callsign); 518 514 519 query.exec(); 520 if (query.isActive() && query.size()) 515 if (query.exec() && query.next()) 521 516 { 522 517 // got match 523 query.first();524 518 m_localChanID_text->SetText(query.value(0).toString()); 525 519 m_localChanNo_text->SetText(query.value(1).toString()); 526 520 m_localChanName_text->SetText(query.value(2).toString()); … … 564 558 querystr = QString("SELECT %1 FROM channel ORDER BY %2").arg(field).arg(field); 565 559 566 560 MSqlQuery query(MSqlQuery::InitCon()); 567 query.exec(querystr);568 561 569 if (query. isActive() && query.size())562 if (query.exec(querystr)) 570 563 { 571 564 while (query.next()) 572 565 { … … 591 584 query.prepare("SELECT chanid, channum, name, callsign " 592 585 "FROM channel WHERE chanid = :CHANID;"); 593 586 query.bindValue(":CHANID", value); 594 query.exec();595 587 596 if (query. isActive() && query.size())588 if (query.exec() && query.next()) 597 589 { 598 query.next();599 590 m_localChanID_text->SetText(query.value(0).toString()); 600 591 m_localChanNo_text->SetText(query.value(1).toString()); 601 592 m_localChanName_text->SetText(query.value(2).toString()); … … 619 610 query.prepare("SELECT chanid, channum, name, callsign " 620 611 "FROM channel WHERE channum = :CHANNUM;"); 621 612 query.bindValue(":CHANNUM", value); 622 query.exec();623 613 624 if (query. isActive() && query.size())614 if (query.exec() && query.next()) 625 615 { 626 query.next();627 616 m_localChanID_text->SetText(query.value(0).toString()); 628 617 m_localChanNo_text->SetText(query.value(1).toString()); 629 618 m_localChanName_text->SetText(query.value(2).toString()); … … 647 636 query.prepare("SELECT chanid, channum, name, callsign " 648 637 "FROM channel WHERE name = :NAME;"); 649 638 query.bindValue(":NAME", value); 650 query.exec();651 639 652 if (query. isActive() && query.size())640 if (query.exec() && query.next()) 653 641 { 654 query.next();655 642 m_localChanID_text->SetText(query.value(0).toString()); 656 643 m_localChanNo_text->SetText(query.value(1).toString()); 657 644 m_localChanName_text->SetText(query.value(2).toString()); … … 675 662 query.prepare("SELECT chanid, channum, name, callsign " 676 663 "FROM channel WHERE callsign = :CALLSIGN;"); 677 664 query.bindValue(":CALLSIGN", value); 678 query.exec();679 665 680 if (query. isActive() && query.size())666 if (query.exec() && query.next()) 681 667 { 682 query.next();683 668 m_localChanID_text->SetText(query.value(0).toString()); 684 669 m_localChanNo_text->SetText(query.value(1).toString()); 685 670 m_localChanName_text->SetText(query.value(2).toString()); -
mytharchive/mytharchivehelper/main.cpp
old new 439 439 query.bindValue(":CHANID", chanID); 440 440 query.bindValue(":STARTTIME", startTime); 441 441 442 query.exec(); 443 if (query.isActive() && query.size()) 442 if (query.exec() && query.next()) 444 443 { 445 query.first();446 444 QDomElement elem; 447 445 QDomText text; 448 446 … … 628 626 "FROM channel WHERE chanid = :CHANID;"); 629 627 query.bindValue(":CHANID", chanID); 630 628 631 query.exec(); 632 if (query.isActive() && query.size()) 629 if (query.exec() && query.next()) 633 630 { 634 query.first();635 631 QDomElement channel = doc.createElement("channel"); 636 632 channel.setAttribute("chanid", query.value(0).toString()); 637 633 channel.setAttribute("channum", query.value(1).toString()); … … 662 658 query.bindValue(":CHANID", chanID); 663 659 query.bindValue(":STARTTIME", startTime); 664 660 665 query.exec(); 666 if (query.isActive() && query.size()) 661 if (query.exec() && query.size()) 667 662 { 668 663 QDomElement credits = doc.createElement("credits"); 669 664 while (query.next()) … … 684 679 query.bindValue(":CHANID", chanID); 685 680 query.bindValue(":STARTTIME", startTime); 686 681 687 query.exec(); 688 if (query.isActive() && query.size()) 682 if (query.exec() && query.next()) 689 683 { 690 query.first();691 684 QDomElement rating = doc.createElement("rating"); 692 685 rating.setAttribute("system", query.value(0).toString()); 693 686 rating.setAttribute("rating", query.value(1).toString()); … … 702 695 "WHERE chanid = :CHANID and starttime = :STARTTIME;"); 703 696 query.bindValue(":CHANID", chanID); 704 697 query.bindValue(":STARTTIME", startTime); 705 query.exec(); 706 if (query.isActive() && query.size()) 698 if (query.exec() && query.size()) 707 699 { 708 700 while (query.next()) 709 701 { … … 724 716 "WHERE chanid = :CHANID and starttime = :STARTTIME;"); 725 717 query.bindValue(":CHANID", chanID); 726 718 query.bindValue(":STARTTIME", startTime); 727 query.exec(); 728 if (query.isActive() && query.size()) 719 if (query.exec() && query.size()) 729 720 { 730 721 while (query.next()) 731 722 { … … 821 812 "FROM videometadata WHERE filename = :FILENAME;"); 822 813 query.bindValue(":FILENAME", filename); 823 814 824 query.exec(); 825 if (query.isActive() && query.size()) 815 if (query.exec() && query.next()) 826 816 { 827 query.first();828 817 QDomElement elem; 829 818 QDomText text; 830 819 … … 924 913 "FROM videocategory WHERE intid = :INTID;"); 925 914 query.bindValue(":INTID", categoryID); 926 915 927 query.exec(); 928 if (query.isActive() && query.size()) 916 if (query.exec() && query.next()) 929 917 { 930 query.first();931 918 QDomElement category = doc.createElement("category"); 932 919 category.setAttribute("intid", query.value(0).toString()); 933 920 category.setAttribute("category", query.value(1).toString()); … … 1436 1423 int intid; 1437 1424 query.prepare("SELECT intid FROM videometadata WHERE filename = :FILENAME;"); 1438 1425 query.bindValue(":FILENAME", path + "/" + basename); 1439 if (query.exec() )1426 if (query.exec() && query.next()) 1440 1427 { 1441 query.first();1442 1428 intid = query.value(0).toInt(); 1443 1429 } 1444 1430 else … … 1480 1466 query.prepare("SELECT intid FROM videogenre " 1481 1467 "WHERE genre = :GENRE"); 1482 1468 query.bindValue(":GENRE", genre); 1483 query.exec(); 1484 if (query.isActive() && query.size()) 1469 if (query.exec() && query.next()) 1485 1470 { 1486 query.first();1487 1471 genreID = query.value(0).toInt(); 1488 1472 } 1489 1473 else … … 1491 1475 // genre doesn't exist so add it 1492 1476 query.prepare("INSERT INTO videogenre (genre) VALUES(:GENRE);"); 1493 1477 query.bindValue(":GENRE", genre); 1494 query.exec(); 1478 if (!query.exec()) 1479 MythDB::DBError("NativeArchive::importVideo - " 1480 "insert videogenre", query); 1495 1481 1496 1482 // get new intid of genre 1497 1483 query.prepare("SELECT intid FROM videogenre " 1498 1484 "WHERE genre = :GENRE"); 1499 1485 query.bindValue(":GENRE", genre); 1500 query.exec(); 1501 if (query.isActive() && query.size()) 1486 if (query.exec() && query.next()) 1502 1487 { 1503 query.first();1504 1488 genreID = query.value(0).toInt(); 1505 1489 } 1506 1490 else … … 1515 1499 "VALUES (:IDVIDEO, :IDGENRE);"); 1516 1500 query.bindValue(":IDVIDEO", intid); 1517 1501 query.bindValue(":IDGENRE", genreID); 1518 query.exec(); 1502 if (!query.exec()) 1503 MythDB::DBError("NativeArchive::importVideo - " 1504 "insert videometadatagenre", query); 1519 1505 } 1520 1506 1521 1507 VERBOSE(VB_JOBQUEUE, "Inserted genre details into database"); … … 1551 1537 query.prepare("SELECT intid FROM videocountry " 1552 1538 "WHERE country = :COUNTRY"); 1553 1539 query.bindValue(":COUNTRY", country); 1554 query.exec(); 1555 if (query.isActive() && query.size()) 1540 if (query.exec() && query.next()) 1556 1541 { 1557 query.first();1558 1542 countryID = query.value(0).toInt(); 1559 1543 } 1560 1544 else … … 1562 1546 // country doesn't exist so add it 1563 1547 query.prepare("INSERT INTO videocountry (country) VALUES(:COUNTRY);"); 1564 1548 query.bindValue(":COUNTRY", country); 1565 query.exec(); 1549 if (!query.exec()) 1550 MythDB::DBError("NativeArchive::importVideo - " 1551 "insert videocountry", query); 1566 1552 1567 1553 // get new intid of country 1568 1554 query.prepare("SELECT intid FROM videocountry " 1569 1555 "WHERE country = :COUNTRY"); 1570 1556 query.bindValue(":COUNTRY", country); 1571 query.exec(); 1572 if (query.isActive() && query.size()) 1557 if (query.exec() && query.next()) 1573 1558 { 1574 query.first();1575 1559 countryID = query.value(0).toInt(); 1576 1560 } 1577 1561 else … … 1586 1570 "VALUES (:IDVIDEO, :IDCOUNTRY);"); 1587 1571 query.bindValue(":IDVIDEO", intid); 1588 1572 query.bindValue(":IDCOUNTRY", countryID); 1589 query.exec(); 1573 if (!query.exec()) 1574 MythDB::DBError("NativeArchive::importVideo - " 1575 "insert videometadatacountry", query); 1590 1576 } 1591 1577 1592 1578 VERBOSE(VB_JOBQUEUE, "Inserted country details into database"); … … 1609 1595 query.prepare("SELECT intid FROM videocategory " 1610 1596 "WHERE category = :CATEGORY"); 1611 1597 query.bindValue(":CATEGORY", category); 1612 query.exec(); 1613 if (query.isActive() && query.size()) 1598 if (query.exec() && query.next()) 1614 1599 { 1615 query.first();1616 1600 categoryID = query.value(0).toInt(); 1617 1601 } 1618 1602 else … … 1620 1604 // category doesn't exist so add it 1621 1605 query.prepare("INSERT INTO videocategory (category) VALUES(:CATEGORY);"); 1622 1606 query.bindValue(":CATEGORY", category); 1623 query.exec(); 1607 if (!query.exec()) 1608 MythDB::DBError("NativeArchive::importVideo - " 1609 "insert videocategory", query); 1624 1610 1625 1611 // get new intid of category 1626 1612 query.prepare("SELECT intid FROM videocategory " 1627 1613 "WHERE category = :CATEGORY"); 1628 1614 query.bindValue(":CATEGORY", category); 1629 query.exec(); 1630 if (query.isActive() && query.size()) 1615 if (query.exec() && query.next()) 1631 1616 { 1632 query.first();1633 1617 categoryID = query.value(0).toInt(); 1634 1618 } 1635 1619 else … … 1645 1629 "WHERE intid = :INTID;"); 1646 1630 query.bindValue(":CATEGORY", categoryID); 1647 1631 query.bindValue(":INTID", intid); 1648 query.exec(); 1632 if (!query.exec()) 1633 MythDB::DBError("NativeArchive::importVideo - " 1634 "update category", query); 1649 1635 1650 1636 VERBOSE(VB_JOBQUEUE, "Fixed the category in the database"); 1651 1637 } -
mythbrowser/mythbookmarkmanager/browserdbutil.cpp
old new 193 193 delete siteList.takeFirst(); 194 194 195 195 MSqlQuery query(MSqlQuery::InitCon()); 196 query.exec("SELECT category, name, url FROM websites "197 "ORDER BY category, name");198 196 199 if (!query.isActive()) 197 if (!query.exec("SELECT category, name, url FROM websites " 198 "ORDER BY category, name")) 200 199 { 201 200 VERBOSE(VB_IMPORTANT, "BookmarkManager: Error in loading from DB"); 202 201 } -
mythgallery/mythgallery/galleryutil.cpp
old new 24 24 #include <mythtv/mythdbcon.h> 25 25 #include <mythtv/util.h> 26 26 #include <mythtv/mythdirs.h> 27 #include <mythtv/mythdb.h> 27 28 28 29 // mythgallery 29 30 #include "config.h" … … 636 637 "WHERE image = :IMAGEOLD"); 637 638 subquery.bindValue(":IMAGENEW", newImage); 638 639 subquery.bindValue(":IMAGEOLD", oldImage); 639 subquery.exec(); 640 if (!subquery.exec()) 641 MythDB::DBError("GalleryUtil::RenameDirectory - update image", 642 subquery); 640 643 } 641 644 } 642 645 -
mythgame/mythgame/gamehandler.cpp
old new 13 13 #include <mythtv/mythdbcon.h> 14 14 #include <mythtv/mythdialogs.h> 15 15 #include <mythtv/util.h> 16 #include <mythtv/mythdb.h> 16 17 17 18 #define LOC_ERR QString("MythGame:GAMEHANDLER Error: ") 18 19 #define LOC QString("MythGame:GAMEHANDLER: ") … … 50 51 } 51 52 52 53 MSqlQuery query(MSqlQuery::InitCon()); 53 query.exec("SELECT DISTINCT playername FROM gameplayers WHERE playername <> '';"); 54 if (!query.exec("SELECT DISTINCT playername FROM gameplayers " 55 "WHERE playername <> '';")) 56 MythDB::DBError("checkHandlers - selecting playername", query); 54 57 55 58 while (query.next()) 56 59 { … … 75 78 76 79 query.bindValue(":SYSTEM", handler->SystemName()); 77 80 78 query.exec(); 79 80 query.next(); 81 handler->rompath = query.value(0).toString(); 82 handler->workingpath = query.value(1).toString(); 83 handler->commandline = query.value(2).toString(); 84 handler->screenshots = query.value(3).toString(); 85 handler->gameplayerid = query.value(4).toInt(); 86 handler->gametype = query.value(5).toString(); 87 handler->validextensions = QStringList::split(",", query.value(6).toString().stripWhiteSpace().remove(" ")); 88 handler->spandisks = query.value(7).toInt(); 81 if (query.exec() && query.next()) 82 { 83 handler->rompath = query.value(0).toString(); 84 handler->workingpath = query.value(1).toString(); 85 handler->commandline = query.value(2).toString(); 86 handler->screenshots = query.value(3).toString(); 87 handler->gameplayerid = query.value(4).toInt(); 88 handler->gametype = query.value(5).toString(); 89 handler->validextensions = QStringList::split(",", 90 query.value(6).toString().stripWhiteSpace().remove(" ")); 91 handler->spandisks = query.value(7).toInt(); 92 } 89 93 90 94 } 91 95 … … 118 122 "binfile FROM romdb WHERE platform = :GAMETYPE;"); 119 123 120 124 query.bindValue(":GAMETYPE",GameType); 121 query.exec();122 125 123 if (query. isActive() && query.size() > 0)126 if (query.exec()) 124 127 { 125 128 while (query.next()) 126 129 { … … 207 210 query.bindValue(":ROMNAME",filename); 208 211 query.bindValue(":ROMPATH",RomPath); 209 212 210 query.exec(); 213 if (!query.exec()) 214 MythDB::DBError("purgeGameDB", query); 211 215 212 216 } 213 217 … … 263 267 query.bindValue(":ROMNAME", romname); 264 268 query.bindValue(":SYSTEM", Systemname); 265 269 266 query.exec(); 270 if (!query.exec()) 271 MythDB::DBError("updateDisplayRom", query); 267 272 268 273 } 269 274 … … 277 282 query.bindValue(":ROMNAME", romname); 278 283 query.bindValue(":GAMETYPE",GameType); 279 284 280 query.exec(); 285 if (!query.exec()) 286 MythDB::DBError("updateDiskCount", query); 281 287 282 288 } 283 289 … … 291 297 query.bindValue(":ROMNAME", romname); 292 298 query.bindValue(":SYSTEM", Systemname); 293 299 294 query.exec(); 300 if (!query.exec()) 301 MythDB::DBError("updateGameName", query); 295 302 296 303 } 297 304 … … 321 328 322 329 query.bindValue(":GAMETYPE",GameType); 323 330 324 query.exec(); 325 326 if (query.isActive() && query.size() > 0) 331 if (query.exec()) 327 332 { 328 333 while (query.next()) 329 334 { … … 464 469 query.bindValue(":PUBLISHER", Publisher); 465 470 query.bindValue(":VERSION", Version); 466 471 467 query.exec(); 472 if (!query.exec()) 473 MythDB::DBError("GameHandler::UpdateGameDB - " 474 "insert gamemetadata", query); 468 475 } 469 476 else if ((iter.data().FoundLoc() == inDatabase) && (removalprompt)) 470 477 { … … 490 497 491 498 query.bindValue(":SYSTEM",handler->SystemName()); 492 499 493 query.exec(); 500 if (!query.exec()) 501 MythDB::DBError("GameHandler::VerifyGameDB - " 502 "select", query); 494 503 495 504 MythProgressDialog *progressDlg = new MythProgressDialog( 496 505 QObject::tr("Verifying %1 files").arg(handler->SystemName()), … … 599 608 break; 600 609 case kDialogCodeButton1: 601 610 MSqlQuery query(MSqlQuery::InitCon()); 602 query.exec("DELETE FROM gamemetadata;"); 611 if (!query.exec("DELETE FROM gamemetadata;")) 612 MythDB::DBError("GameHandler::clearAllGameData - " 613 "delete gamemetadata", query); 603 614 break; 604 615 }; 605 616 } -
mythgame/mythgame/dbcheck.cpp
old new 199 199 { 200 200 201 201 if (!gContext->GetSetting("GameAllTreeLevels").isEmpty()) 202 query.exec("UPDATE settings SET data = 'system gamename' WHERE value = 'GameAllTreeLevels'; "); 202 if (!query.exec("UPDATE settings SET data = 'system gamename' " 203 "WHERE value = 'GameAllTreeLevels'; ")) 204 MythDB::DBError("update GameAllTreeLevels", query); 203 205 204 206 QString updates[] = { 205 207 "ALTER TABLE gamemetadata ADD COLUMN country varchar(128) NOT NULL default ''; ", -
mythgame/mythgame/gametree.cpp
old new 568 568 query.bindValue(":GAMENAME", curItem->m_romInfo->Gamename()); 569 569 } 570 570 571 query.exec();572 571 573 if (query. isActive() && query.size() > 0)572 if (query.exec()) 574 573 { 575 574 while (query.next()) 576 575 { -
mythgame/mythgame/rominfo.cpp
old new 217 217 query.prepare(thequery); 218 218 query.bindValue(":SYSTEM", system); 219 219 query.bindValue(":GAMENAME", gamename); 220 query.exec();221 220 222 if (query. next())221 if (query.exec() && query.next()) 223 222 { 224 223 setSystem(query.value(0).toString()); 225 224 setGamename(query.value(1).toString()); … … 239 238 query.prepare("SELECT screenshots FROM gameplayers " 240 239 "WHERE playername = :SYSTEM"); 241 240 query.bindValue(":SYSTEM",system); 242 query.exec();243 241 244 if (query. next())242 if (query.exec() && query.next()) 245 243 { 246 244 if (!query.value(0).toString().isEmpty()) 247 245 { … … 262 260 query.prepare("SELECT DISTINCT system FROM gamemetadata " 263 261 "WHERE romname = :ROMNAME"); 264 262 query.bindValue(":ROMNAME", Romname()); 265 query.exec(); 263 if (!query.exec()) 264 MythDB::DBError("RomInfo::fillData - selecting systems", query); 266 265 267 266 while (query.next()) 268 267 { -
mythmusic/mythmusic/main.cpp
old new 111 111 query.bindValue(":DATA", pending); 112 112 query.bindValue(":HOST", gContext->GetHostName()); 113 113 114 query.exec(); 114 if (!query.exec()) 115 MythDB::DBError("SavePending - inserting LastMusicPlaylistPush", 116 query); 115 117 } 116 118 else if (query.size() == 1) 117 119 { … … 123 125 query.bindValue(":LASTPUSH", "LastMusicPlaylistPush"); 124 126 query.bindValue(":HOST", gContext->GetHostName()); 125 127 126 query.exec(); 128 if (!query.exec()) 129 MythDB::DBError("SavePending - updating LastMusicPlaylistPush", 130 query); 127 131 } 128 132 else 129 133 { … … 135 139 "AND hostname = :HOST ;"); 136 140 query.bindValue(":LASTPUSH", "LastMusicPlaylistPush"); 137 141 query.bindValue(":HOST", gContext->GetHostName()); 138 query.exec(); 142 if (!query.exec()) 143 MythDB::DBError("SavePending - deleting LastMusicPlaylistPush", 144 query); 139 145 140 146 query.prepare("INSERT INTO settings (value,data,hostname) VALUES " 141 147 "(:LASTPUSH, :DATA, :HOST );"); … … 143 149 query.bindValue(":DATA", pending); 144 150 query.bindValue(":HOST", gContext->GetHostName()); 145 151 146 query.exec(); 152 if (!query.exec()) 153 MythDB::DBError("SavePending - inserting LastMusicPlaylistPush (2)", 154 query); 147 155 } 148 156 } 149 157 … … 428 436 CheckFreeDBServerFile(); 429 437 430 438 MSqlQuery count_query(MSqlQuery::InitCon()); 431 count_query.exec("SELECT COUNT(*) FROM music_songs;");432 439 433 440 bool musicdata_exists = false; 434 if (count_query. isActive())441 if (count_query.exec("SELECT COUNT(*) FROM music_songs;")) 435 442 { 436 443 if(count_query.next() && 437 444 0 != count_query.value(0).toInt()) -
mythmusic/mythmusic/metadata.cpp
old new 410 410 else 411 411 query.bindValue(":ID", m_id); 412 412 413 query.exec(); 413 if (!query.exec()) 414 MythDB::DBError("Metadata::dumpToDatabase - updating music_songs", 415 query); 414 416 415 417 if (m_id < 1 && query.isActive() && 1 == query.numRowsAffected()) 416 418 m_id = query.lastInsertId().toInt(); … … 424 426 "song_id=:SONGID AND imagetype=:TYPE;"); 425 427 query.bindValue(":TYPE", (*it).imageType); 426 428 query.bindValue(":SONGID", m_id); 427 query.exec();428 429 429 if (query. next())430 if (query.exec() && query.next()) 430 431 { 431 432 int artid = query.value(0).toInt(); 432 433 … … 449 450 query.bindValue(":SONGID", m_id); 450 451 query.bindValue(":EMBED", 1); 451 452 452 query.exec(); 453 if (!query.exec()) 454 MythDB::DBError("Metadata::dumpToDatabase - " 455 "inserting music_albumart", query); 453 456 } 454 457 } 455 458 … … 821 824 MSqlQuery query(MSqlQuery::InitCon()); 822 825 query.prepare(aquery); 823 826 query.bindValue(":TRACKID", id); 824 query.exec();825 827 826 if (query. isActive() && query.size() > 0)828 if (query.exec() && query.next()) 827 829 { 828 query.next();829 830 filename = query.value(9).toString(); 830 831 if (!filename.contains("://")) 831 832 filename = m_startdir + filename; … … 985 986 QString filename, artist, album, title; 986 987 987 988 MSqlQuery query(MSqlQuery::InitCon()); 988 query.exec(aquery); 989 if (!query.exec(aquery)) 990 MythDB::DBError("AllMusic::resync", query); 989 991 990 992 m_root_node->clear(); 991 993 m_all_music.clear(); -
mythmusic/mythmusic/dbcheck.cpp
old new 115 115 116 116 MSqlQuery query(MSqlQuery::InitCon()); 117 117 // urls as filenames are NOT officially supported yet 118 query.exec("SELECT filename, intid FROM musicmetadata WHERE " 119 "filename NOT LIKE ('%://%');"); 120 121 if (query.isActive() && query.size() > 0) 118 if (query.exec("SELECT filename, intid FROM musicmetadata WHERE " 119 "filename NOT LIKE ('%://%');")) 122 120 { 123 121 int i = 0; 124 122 QString intid, name, newname; … … 133 131 if (newname.startsWith(startdir)) 134 132 { 135 133 newname.remove(0, startdir.length()); 136 modify.exec(QString("UPDATE musicmetadata SET " 137 "filename = \"%1\" " 138 "WHERE filename = \"%2\" AND intid = %3;") 139 .arg(newname).arg(name).arg(intid)); 140 if (modify.isActive()) 134 if (modify.exec(QString("UPDATE musicmetadata SET " 135 "filename = \"%1\" " 136 "WHERE filename = \"%2\" AND intid = %3;") 137 .arg(newname).arg(name).arg(intid))) 141 138 i += modify.numRowsAffected(); 142 139 } 143 140 } -
mythmusic/mythmusic/filescanner.cpp
old new 351 351 MSqlQuery query(MSqlQuery::InitCon()); 352 352 MSqlQuery deletequery(MSqlQuery::InitCon()); 353 353 354 query.exec("SELECT g.genre_id FROM music_genres g LEFT JOIN music_songs s " 355 "ON g.genre_id=s.genre_id WHERE s.genre_id IS NULL;"); 354 if (!query.exec("SELECT g.genre_id FROM music_genres g " 355 "LEFT JOIN music_songs s ON g.genre_id=s.genre_id " 356 "WHERE s.genre_id IS NULL;")) 357 MythDB::DBError("FileScanner::cleanDB - select music_genres", query); 356 358 while (query.next()) 357 359 { 358 360 int genreid = query.value(0).toInt(); 359 361 deletequery.prepare("DELETE FROM music_genres WHERE genre_id=:GENREID"); 360 362 deletequery.bindValue(":GENREID", genreid); 361 deletequery.exec(); 363 if (!deletequery.exec()) 364 MythDB::DBError("FileScanner::cleanDB - delete music_genres", 365 deletequery); 362 366 } 363 367 364 368 if (clean_progress) 365 369 clean_progress->SetProgress(++counter); 366 370 367 query.exec("SELECT a.album_id FROM music_albums a LEFT JOIN music_songs s " 368 "ON a.album_id=s.album_id WHERE s.album_id IS NULL;"); 371 if (!query.exec("SELECT a.album_id FROM music_albums a " 372 "LEFT JOIN music_songs s ON a.album_id=s.album_id " 373 "WHERE s.album_id IS NULL;")) 374 MythDB::DBError("FileScanner::cleanDB - select music_albums", query); 369 375 while (query.next()) 370 376 { 371 377 int albumid = query.value(0).toInt(); 372 378 deletequery.prepare("DELETE FROM music_albums WHERE album_id=:ALBUMID"); 373 379 deletequery.bindValue(":ALBUMID", albumid); 374 deletequery.exec(); 380 if (!deletequery.exec()) 381 MythDB::DBError("FileScanner::cleanDB - delete music_albums", 382 deletequery); 375 383 } 376 384 377 385 if (clean_progress) 378 386 clean_progress->SetProgress(++counter); 379 387 380 query.exec("SELECT a.artist_id FROM music_artists a " 381 "LEFT JOIN music_songs s ON a.artist_id=s.artist_id " 382 "LEFT JOIN music_albums l ON a.artist_id=l.artist_id " 383 "WHERE s.artist_id IS NULL AND l.artist_id IS NULL"); 388 if (!query.exec("SELECT a.artist_id FROM music_artists a " 389 "LEFT JOIN music_songs s ON a.artist_id=s.artist_id " 390 "LEFT JOIN music_albums l ON a.artist_id=l.artist_id " 391 "WHERE s.artist_id IS NULL AND l.artist_id IS NULL")) 392 MythDB::DBError("FileScanner::cleanDB - select music_artists", query); 384 393 while (query.next()) 385 394 { 386 395 int artistid = query.value(0).toInt(); 387 396 deletequery.prepare("DELETE FROM music_artists WHERE artist_id=:ARTISTID"); 388 397 deletequery.bindValue(":ARTISTID", artistid); 389 deletequery.exec(); 398 if (!deletequery.exec()) 399 MythDB::DBError("FileScanner::cleanDB - delete music_artists", 400 deletequery); 390 401 } 391 402 392 403 if (clean_progress) 393 404 clean_progress->SetProgress(++counter); 394 405 395 query.exec("SELECT a.albumart_id FROM music_albumart a LEFT JOIN " 396 "music_songs s ON a.song_id=s.song_id WHERE " 397 "embedded='1' AND s.song_id IS NULL;"); 406 if (!query.exec("SELECT a.albumart_id FROM music_albumart a LEFT JOIN " 407 "music_songs s ON a.song_id=s.song_id WHERE " 408 "embedded='1' AND s.song_id IS NULL;")) 409 MythDB::DBError("FileScanner::cleanDB - select music_albumart", query); 398 410 while (query.next()) 399 411 { 400 412 int albumartid = query.value(0).toInt(); 401 413 deletequery.prepare("DELETE FROM music_albumart WHERE albumart_id=:ALBUMARTID"); 402 414 deletequery.bindValue(":ALBUMARTID", albumartid); 403 deletequery.exec(); 415 if (!deletequery.exec()) 416 MythDB::DBError("FileScanner::cleanDB - delete music_albumart", 417 deletequery); 404 418 } 405 419 406 420 if (clean_progress) … … 449 463 MSqlQuery query(MSqlQuery::InitCon()); 450 464 query.prepare("DELETE FROM music_songs WHERE filename = :NAME ;"); 451 465 query.bindValue(":NAME", sqlfilename); 452 query.exec(); 466 if (!query.exec()) 467 MythDB::DBError("FileScanner::RemoveFileFromDB - deleting music_songs", 468 query); 453 469 } 454 470 455 471 /*! … … 622 638 MusicLoadedMap::Iterator iter; 623 639 624 640 MSqlQuery query(MSqlQuery::InitCon()); 625 query.exec("SELECT CONCAT_WS('/', path, filename), date_modified " 626 "FROM music_songs LEFT JOIN music_directories " 627 "ON music_songs.directory_id=music_directories.directory_id " 628 "WHERE filename NOT LIKE ('%://%')"); 641 if (!query.exec("SELECT CONCAT_WS('/', path, filename), date_modified " 642 "FROM music_songs LEFT JOIN music_directories ON " 643 "music_songs.directory_id=music_directories.directory_id " 644 "WHERE filename NOT LIKE ('%://%')")) 645 MythDB::DBError("FileScanner::ScanMusic", query); 629 646 630 647 uint counter = 0; 631 648 … … 693 710 MusicLoadedMap::Iterator iter; 694 711 695 712 MSqlQuery query(MSqlQuery::InitCon()); 696 query.exec("SELECT CONCAT_WS('/', path, filename) " 697 "FROM music_albumart LEFT JOIN music_directories " 698 "ON music_albumart.directory_id=music_directories.directory_id " 699 "WHERE music_albumart.embedded=0"); 713 if (!query.exec("SELECT CONCAT_WS('/', path, filename) " 714 "FROM music_albumart LEFT JOIN music_directories ON " 715 "music_albumart.directory_id=music_directories.directory_id" 716 " WHERE music_albumart.embedded=0")) 717 MythDB::DBError("FileScanner::ScanArtwork", query); 700 718 701 719 uint counter = 0; 702 720 -
mythmusic/mythmusic/playlist.cpp
old new 440 440 query.bindValue(":ID", id); 441 441 query.bindValue(":HOST", a_host); 442 442 443 query.exec(); 443 if (!query.exec()) 444 MythDB::DBError("Playlist::loadPlaylistByID", query); 444 445 445 446 while (query.next()) 446 447 { … … 697 698 "FROM music_smartplaylist_items " 698 699 "WHERE smartplaylistid = :ID;"); 699 700 query.bindValue(":ID", ID); 700 query.exec(); 701 if (query.isActive() && query.size() > 0) 701 if (query.exec()) 702 702 { 703 703 bool bFirst = true; 704 704 while (query.next()) … … 773 773 "WHERE playlist_id = :ID ;"); 774 774 an_int *= -1; 775 775 query.bindValue(":ID", an_int); 776 query.exec();777 776 778 if (query. size() > 0)777 if (query.exec() && query.next()) 779 778 { 780 query.next();781 779 length = query.value(0).toInt(); 782 780 } 783 781 } -
mythmusic/mythmusic/smartplaylist.cpp
old new 1727 1727 listView->clear(); 1728 1728 1729 1729 MSqlQuery query(MSqlQuery::InitCon()); 1730 query.exec(sql);1731 1730 1732 if (query. last())1731 if (query.exec(sql) && query.last()) 1733 1732 { 1734 1733 do 1735 1734 { -
mythvideo/mythvideo/metadata.cpp
old new 587 587 { 588 588 // Must make sure we have 'id' filled before we call updateGenres or 589 589 // updateCountries 590 query.exec("SELECT LAST_INSERT_ID()");591 590 592 if (!query. isActive() || query.size() < 1)591 if (!query.exec("SELECT LAST_INSERT_ID()") || !query.next()) 593 592 { 594 593 MythDB::DBError("metadata id get", query); 595 594 return; 596 595 } 597 596 598 query.next();599 597 m_id = query.value(0).toUInt(); 600 598 601 599 if (0 == m_id) -
mythvideo/mythvideo/dbcheck.cpp
old new 50 50 { 51 51 MSqlQuery query(MSqlQuery::InitCon()); 52 52 53 query.exec(QString("DELETE FROM settings WHERE value='%1';") 54 .arg(field_name)); 55 query.exec(QString("INSERT INTO settings (value, data, hostname) " 56 "VALUES ('%1', %2, NULL);") 57 .arg(field_name).arg(newnumber)); 53 if (!query.exec(QString("DELETE FROM settings WHERE value='%1';") 54 .arg(field_name))) 55 MythDB::DBError("UpdateDBVersionNumber - delete", query); 56 if (!query.exec(QString("INSERT INTO settings (value, data, hostname) " 57 "VALUES ('%1', %2, NULL);") 58 .arg(field_name).arg(newnumber))) 59 MythDB::DBError("UpdateDBVersionNumber - insert", query); 58 60 59 61 VERBOSE(VB_IMPORTANT, 60 62 QString("Upgraded to MythVideo schema version %1") … … 73 75 for (QStringList::const_iterator p = updates.begin(); 74 76 p != updates.end(); ++p) 75 77 { 76 query.exec(*p); 78 if (!query.exec(*p)) 79 MythDB::DBError("performActualUpdate", query); 77 80 } 78 81 79 82 UpdateDBVersionNumber(field_name, version); … … 131 134 performActualUpdate(updates, "1000", dbver, OldMythVideoVersionName); 132 135 133 136 MSqlQuery qQuery(MSqlQuery::InitCon()); 134 qQuery.exec("SELECT * FROM videotypes;");135 137 136 if (!qQuery. isActive() || qQuery.size() <= 0)138 if (!qQuery.exec("SELECT * FROM videotypes;") || qQuery.size() <= 0) 137 139 { 138 140 const QString updates2[] = { 139 141 "INSERT INTO videotypes (extension, playcommand, f_ignore, use_default)" … … 292 294 QStringList updates; 293 295 294 296 MSqlQuery query(MSqlQuery::InitCon()); 295 query.exec("SELECT intid FROM videocategory;");296 297 297 if (query. isActive() && query.size())298 if (query.exec("SELECT intid FROM videocategory;") && query.size()) 298 299 { 299 300 QString categoryIDs = "'0'"; 300 301 while (query.next()) … … 317 318 if (dbver == "1009") 318 319 { 319 320 MSqlQuery query(MSqlQuery::InitCon()); 320 query.exec("SELECT extension, playcommand FROM videotypes");321 321 322 322 QRegExp extChange("^(img|vob|mpeg|mpg|iso|VIDEO_TS)$", 323 323 Qt::CaseInsensitive); 324 324 QStringList updates; 325 if (query. isActive() && query.size())325 if (query.exec("SELECT extension, playcommand FROM videotypes")) 326 326 { 327 327 while (query.next()) 328 328 { … … 355 355 "Inserting MythDVD initial database information."); 356 356 357 357 MSqlQuery qQuery(MSqlQuery::InitCon()); 358 qQuery.exec("SELECT * FROM dvdinput;");359 358 360 if (!qQuery. isActive() || qQuery.size() <= 0)359 if (!qQuery.exec("SELECT * FROM dvdinput;") || qQuery.size() <= 0) 361 360 { 362 361 const QString updates[] = { 363 362 "CREATE TABLE IF NOT EXISTS dvdinput (" … … 416 415 performActualUpdate(updates, "1000", dbver, OldMythDVDVersionName); 417 416 } 418 417 419 qQuery.exec("SELECT * FROM dvdtranscode;"); 420 if (!qQuery.isActive() || qQuery.size() <= 0) 418 if (!qQuery.exec("SELECT * FROM dvdtranscode;") || qQuery.size() <= 0) 421 419 { 422 420 const QString updates[] = { 423 421 "CREATE TABLE IF NOT EXISTS dvdtranscode (" -
mythvideo/mythvideo/dbaccess.cpp
old new 66 66 MSqlQuery query(MSqlQuery::InitCon()); 67 67 query.prepare(m_insert_sql); 68 68 query.bindValue(":NAME", name); 69 if (query.exec() && query.isActive())69 if (query.exec()) 70 70 { 71 query.exec("SELECT LAST_INSERT_ID()"); 72 if (query.isActive() && query.size() > 0) 71 if (query.exec("SELECT LAST_INSERT_ID()") && query.next()) 73 72 { 74 query.next();75 73 id = query.value(0).toInt(); 76 74 m_entries.insert(entry_map::value_type(id, name)); 77 75 m_dirty = true; … … 178 176 m_entries.clear(); 179 177 180 178 MSqlQuery query(MSqlQuery::InitCon()); 181 query.exec(m_fill_sql);182 179 183 if (query. isActive() && query.size() > 0)180 if (query.exec(m_fill_sql)) 184 181 { 185 182 while (query.next()) 186 183 { … … 406 403 m_val_map.clear(); 407 404 408 405 MSqlQuery query(MSqlQuery::InitCon()); 409 query.exec(m_fill_sql);410 406 411 if (query. isActive() && query.size() > 0)407 if (query.exec(m_fill_sql) && query.size() > 0) 412 408 { 413 409 id_map::iterator p = m_val_map.end(); 414 410 while (query.next()) … … 664 660 { 665 661 if (!existing_fa) 666 662 { 667 query.exec("SELECT LAST_INSERT_ID()"); 668 if (query.isActive() && query.size() > 0) 663 if (query.exec("SELECT LAST_INSERT_ID()") && query.next()) 669 664 { 670 query.next();671 665 ret_fa.id = query.value(0).toUInt(); 672 666 m_file_associations.push_back(ret_fa); 673 667 } … … 756 750 void fill_from_db() 757 751 { 758 752 MSqlQuery query(MSqlQuery::InitCon()); 759 query.exec("SELECT intid, extension, playcommand, f_ignore, " 760 "use_default FROM videotypes"); 761 if (query.isActive() && query.size() > 0) 753 if (query.exec("SELECT intid, extension, playcommand, f_ignore, " 754 "use_default FROM videotypes")) 762 755 { 763 756 while (query.next()) 764 757 { -
mythvideo/mythvideo/titledialog.cpp
old new 156 156 .arg(m_currentTitle->getInputID()); 157 157 158 158 MSqlQuery a_query(MSqlQuery::InitCon()); 159 a_query.exec(q_string);160 159 161 if(a_query. isActive() && a_query.size() > 0)160 if(a_query.exec(q_string)) 162 161 { 163 162 while(a_query.next()) 164 163 { -
mythmovies/mythmovies/moviesui.cpp
old new 200 200 QString currentDate = QDate::currentDate().toString(); 201 201 202 202 MSqlQuery query(MSqlQuery::InitCon()); 203 query.exec("truncate table movies_showtimes"); 204 query.exec("truncate table movies_movies"); 205 query.exec("truncate table movies_theaters"); 203 if (!query.exec("truncate table movies_showtimes")) 204 MythDB::DBError("truncating movies_showtimes", query); 205 if (!query.exec("truncate table movies_movies")) 206 MythDB::DBError("truncating movies_movies", query); 207 if (!query.exec("truncate table movies_theaters")) 208 MythDB::DBError("truncating movies_theaters", query); 206 209 207 210 QString grabber = gContext->GetSetting("MythMovies.Grabber"); 208 211 grabber.replace("%z", gContext->GetSetting("MythMovies.ZipCode")); -
mythweather/mythweather/sourceManager.cpp
old new 102 102 db.prepare("SELECT sourceid, path FROM weathersourcesettings " 103 103 "WHERE hostname = :HOST;"); 104 104 db.bindValue(":HOST", gContext->GetHostName()); 105 db.exec(); 105 if (!db.exec()) 106 MythDB::DBError("SourceManager::findScripts - select", query); 106 107 QStringList toRemove; 107 108 while (db.next()) 108 109 { -
mythweather/mythweather/weatherSetup.cpp
old new 5 5 // MythTV headers 6 6 #include <mythdbcon.h> 7 7 #include <mythprogressdialog.h> 8 #include <mythtv/mythdb.h> 8 9 9 10 // MythWeather headers 10 11 #include "weatherScreen.h" … … 406 407 QString query = "DELETE FROM weatherscreens WHERE hostname=:HOST"; 407 408 db.prepare(query); 408 409 db.bindValue(":HOST", gContext->GetHostName()); 409 db.exec(); 410 if (!db.exec()) 411 MythDB::DBError("ScreenSetup::saveData - delete weatherscreens", db); 410 412 411 413 query = "INSERT into weatherscreens (draworder, container, units, hostname) " 412 414 "VALUES (:DRAW, :CONT, :UNITS, :HOST);"; -
mythweather/mythweather/weatherSource.cpp
old new 524 524 "WHERE sourceid = :ID AND " 525 525 "TIMESTAMPADD(SECOND,update_timeout,updated) > NOW()"); 526 526 db.bindValue(":ID", getId()); 527 db.exec(); 528 if (db.size() > 0) 527 if (db.exec() && db.size() > 0) 529 528 { 530 529 VERBOSE(VB_IMPORTANT, QString("%1 recently updated, skipping.") 531 530 .arg(m_info->name));