0

query が空の場合、コードは実行されません。これを複数のバリエーションで試しました。ここに簡単なコードがあります。

   mysqlpp::Query query = conn.query();
   query << "SELECT * FROM users WHERE username= " 
         << mysqlpp::quote_only << username 
         << "AND password= " 
         << mysqlpp::quote_only << password;

         mysqlpp::StoreQueryResult res = query.store();
         mysqlpp::StoreQueryResult::const_iterator it;
         for (it = res.begin(); it != res.end(); ++it)
         {
              mysqlpp::Row row = *it;
              if (!row.empty())
              {
              // user name and password match, log them in
              std::cout << "You are logged" << std::endl;
              // rest of code goes here   
              }

              else if (row.empty())  // even just 'else' doesnt get executed
              {
              // no username or password that matches with user input
              std::cout << "Wrong username or password" <<  std::endl; 
              // rest of code goes here 
              // this never get executed, and i have no idea why
              }   
         }

行が空かどうかを確認する方法は? 私は彼らのリファレンスマニュアルで見つけたほとんどすべてを試しましたが、それでも何もしませんでした。

4

0 に答える 0