Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/commonal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.90 by tani, Mon May 23 08:00:30 2005 UTC revision 1.91 by tani, Tue Jun 7 01:10:33 2005 UTC
# Line 22  Line 22 
22   *   *
23   * $Revision$   * $Revision$
24   * $Log$   * $Log$
25     * Revision 1.91  2005/06/07 01:10:33  tani
26     * SQLGetDataの引数を修正.
27     * SQLExecDirectの代わりにSQLExecuteの利用.
28     *
29   * Revision 1.90  2005/05/23 08:00:30  tani   * Revision 1.90  2005/05/23 08:00:30  tani
30   * insertGroup, updateGroup: グループ名が重複した場合はエラーコードを返す.   * insertGroup, updateGroup: グループ名が重複した場合はエラーコードを返す.
31   *   *
# Line 760  static result_t getXoopsModuleConfigValu Line 764  static result_t getXoopsModuleConfigValu
764          SQLLEN cbModule = SQL_NTS, cbKey = SQL_NTS;          SQLLEN cbModule = SQL_NTS, cbKey = SQL_NTS;
765          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule );          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule );
766          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key),    0, (SQLCHAR *)key,    0, &cbKey );          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key),    0, (SQLCHAR *)key,    0, &cbKey );
767          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){          sqlcode = SQLExecute( hstmt );
768            if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
769              if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
770                  string s = getResultCol( hstmt, 1 );                  string s = getResultCol( hstmt, 1 );
771                  *value = new char[s.length()+1];                  *value = new char[s.length()+1];
# Line 3247  result_t loginUser(const char* uname, co Line 3252  result_t loginUser(const char* uname, co
3252          SQLLEN cbUname = SQL_NTS, cbPasswd = SQL_NTS;          SQLLEN cbUname = SQL_NTS, cbPasswd = SQL_NTS;
3253          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname );          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname );
3254          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd );          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd );
3255          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){          sqlcode = SQLExecute( hstmt );
3256            if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
3257              SQLUINTEGER sUID = 0;              SQLUINTEGER sUID = 0;
3258              SQLLEN len = 0;              SQLLEN len = 0;
3259              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len );
# Line 6255  result_t setConfigValue( const char* key Line 6261  result_t setConfigValue( const char* key
6261          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6262              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );
6263              SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );              SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );
6264              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){              sqlcode = SQLExecute( hstmt );
6265                if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6266                  SQLLEN count = 0;                  SQLLEN count = 0;
6267                  if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){                  if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){
6268                      ret = RES_OK;                      ret = RES_OK;
# Line 6266  result_t setConfigValue( const char* key Line 6273  result_t setConfigValue( const char* key
6273                      if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){                      if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6274                          SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );                          SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );
6275                          SQLBindParameter(hstmt2, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );                          SQLBindParameter(hstmt2, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );
6276                          if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                          sqlcode = SQLExecute( hstmt );
6277                            if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6278                              if( ( sqlcode = SQLRowCount( hstmt2, &count ) ) == SQL_SUCCESS && count > 0 ){                              if( ( sqlcode = SQLRowCount( hstmt2, &count ) ) == SQL_SUCCESS && count > 0 ){
6279                                  ret = RES_OK;                                  ret = RES_OK;
6280                              }                              }
# Line 6285  result_t setConfigValue( const char* key Line 6293  result_t setConfigValue( const char* key
6293                      SQLFreeHandle( SQL_HANDLE_STMT, hstmt2 );                      SQLFreeHandle( SQL_HANDLE_STMT, hstmt2 );
6294                  }else{                  }else{
6295                      string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in setConfigValue" );                      string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in setConfigValue" );
6296          s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode );                      s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode );
6297          setLastErrorString( s.c_str( ) );                      setLastErrorString( s.c_str( ) );
6298                      ret = RES_ERROR;                      ret = RES_ERROR;
6299                  }                  }
6300              }else{              }else{
# Line 6333  result_t getConfigValue( const char* key Line 6341  result_t getConfigValue( const char* key
6341          string sql("SELECT value FROM " + dbprefix + "_xoonips_config WHERE name=?");          string sql("SELECT value FROM " + dbprefix + "_xoonips_config WHERE name=?");
6342          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
6343          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6344              SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key, strlen(key), &cbKey );              sqlcode = SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key, 0, &cbKey );
6345              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){              syslog_printf( "SQLBindParameter %d", sqlcode);
6346                if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){
6347                  while( SQLFetch( hstmt ) == SQL_SUCCESS ){                  while( SQLFetch( hstmt ) == SQL_SUCCESS ){
6348                      SQLLEN length = 0;                      SQLLEN length = 0;
6349                      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );                      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
6350                      if( dbtype == DBTYPE_MYSQL ){                      if( dbtype == DBTYPE_MYSQL ){
6351                          // get amount of data                          // get amount of data
6352                          if( SQLGetData(hstmt, 1, SQL_C_BINARY, *value, 0, &length)                          sqlcode = SQLGetData(hstmt, 1, SQL_C_BINARY, value, 0, &length);
6353                              == SQL_SUCCESS_WITH_INFO ){                          syslog_printf( "sqlreturn : %d length %d", sqlcode, length);
6354                                                    if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
6355                              // Get all the data at once.                              // Get all the data at once.
6356                              *value = new char[ length + 1 ];                              *value = new char[ length + 1 ];
6357                              memset( *value, '\0', length + 1 );                              memset( *value, '\0', length + 1 );

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26