zoukankan      html  css  js  c++  java
  • MySql

    int main()
    {
        char server[]= "localhost";
        char user[]= "root";
        char password[]= "***";
        char database[]= "FileNameDataBase";
        MYSQL *C_sql_handle;
        C_sql_handle= mysql_init(nullptr);
        if (!mysql_real_connect(C_sql_handle,server,user,password,database,0,nullptr,0))
        {
            std::cerr<<mysql_error(C_sql_handle)<<"
    ";
            return 0;
        }
        if (mysql_query(C_sql_handle,"set names utf8")) //设置connect编码
        {
            std::cerr<<mysql_error(C_sql_handle)<<"
    ";
            mysql_close(C_sql_handle);
            mysql_library_end;
            return 0;
        }
        if (mysql_query(C_sql_handle,"select hot from FileName where file_name='[阳光电影www.ygdy8.com].囚徒.BD.720p.中英双字幕(1).rmvb'"))
        {
            std::cout<<"failed
    ";
            return 0;
        }
        MYSQL_RES *res= nullptr;
      ///////mysql_store_result/mysql_use_store没有结果集也不返回nullptr而mysql_res结果集data是nullptr res
    = mysql_store_result(C_sql_handle); //mysql_use_result() 如果使用这个救没法用 res检查是否为空,因为mysql_use_result实时,用的时候用mysql_fetch_row取 if (0== res->row_count) { std::cout<<"ok "; } else { MYSQL_ROW row; //行 结构体 while ((row= mysql_fetch_row(res))) { std::cout<<row[0]<<" "; } std::cout<<"no "; } mysql_free_result(res); mysql_close(C_sql_handle); mysql_library_end; std::cout<<"ok ";
       return 0; }
  • 相关阅读:
    gcc数据对齐之: howto 2.
    gcc数据对齐之: howto 1.
    gcc数据结构对齐之:why.
    linux tricks 之 BUILD_BUG_ON_ZERO.
    linux tricks 之 FIELD_SIZEOF.
    linux tricks 之 container_of.
    linux tricks 之 bitmap分析.
    linux tricks 之 roundup.
    Windows之svn问题
    Embeded linux之地址映射
  • 原文地址:https://www.cnblogs.com/Call-C/p/6613274.html
Copyright © 2011-2022 走看看