Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/db.cpp @ 21:a2ad87cad48b
Enhanced the convenience of Cache dialog.
| author | pyon@macmini |
|---|---|
| date | Wed, 17 Dec 2014 00:52:43 +0900 |
| parents | bbd65edf71d4 |
| children |
comparison
equal
deleted
inserted
replaced
| 20:226774bf49fc | 21:a2ad87cad48b |
|---|---|
| 1 // Filename : db.cpp | 1 // Filename : db.cpp |
| 2 // Last Change: 23-May-2014. | 2 // Last Change: 12-Dec-2014. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include <wx/tokenzr.h> | 5 #include <wx/tokenzr.h> |
| 6 #include "db.h" | 6 #include "db.h" |
| 7 #include "wx/wxsqlite3.h" | 7 #include "wx/wxsqlite3.h" |
| 241 | 241 |
| 242 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 242 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
| 243 wxSQLite3Database ccndb; | 243 wxSQLite3Database ccndb; |
| 244 ccndb.Open( gszFile ); | 244 ccndb.Open( gszFile ); |
| 245 | 245 |
| 246 wxSQLite3Statement stmt = ccndb.PrepareStatement( "SELECT date, count(*) FROM ccn GROUP BY date ORDER BY date desc" ); | 246 wxSQLite3Statement stmt = ccndb.PrepareStatement( "SELECT date, count(*) FROM path GROUP BY date ORDER BY date desc" ); |
| 247 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | 247 wxSQLite3ResultSet q = stmt.ExecuteQuery(); |
| 248 | 248 |
| 249 wxString str; | 249 wxString str; |
| 250 if ( !q.IsNull(0) ) { | 250 if ( !q.IsNull(0) ) { |
| 251 while ( q.NextRow() ) { | 251 while ( q.NextRow() ) { |
| 252 str = q.GetString(0) + "_" + q.GetString(1); | 252 //str = q.GetString(0) + "_" + q.GetString(1); |
| 253 str = q.GetString(0); | |
| 253 date_cnt.Add( str ); | 254 date_cnt.Add( str ); |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 stmt.Finalize(); | 257 stmt.Finalize(); |
| 257 ccndb.Close(); | 258 ccndb.Close(); |
| 283 ccndb.Close(); | 284 ccndb.Close(); |
| 284 | 285 |
| 285 return data; | 286 return data; |
| 286 } | 287 } |
| 287 | 288 |
| 288 /* 範囲日時のパスを取得 */ | 289 /* 指定した範囲の日付のパスを取得 */ |
| 289 wxArrayString GetPathes( wxString from, wxString to ) | 290 wxArrayString GetPathesByPeriod( wxString from, wxString to ) |
| 290 { | 291 { |
| 291 wxArrayString path; | 292 wxArrayString path; |
| 292 | 293 |
| 293 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 294 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
| 294 wxSQLite3Database ccndb; | 295 wxSQLite3Database ccndb; |
| 295 ccndb.Open( gszFile ); | 296 ccndb.Open( gszFile ); |
| 296 | 297 |
| 297 wxSQLite3Statement stmt = ccndb.PrepareStatement( "SELECT path FROM path WHERE date >= ? AND date <= ?" ); | 298 wxSQLite3Statement stmt = ccndb.PrepareStatement( "SELECT path FROM path WHERE date >= ? AND date <= ?" ); |
| 298 stmt.Bind( 1, from ); | 299 stmt.Bind( 1, from ); |
| 299 stmt.Bind( 2, to ); | 300 stmt.Bind( 2, to ); |
| 301 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | |
| 302 | |
| 303 if ( !q.IsNull(0) ) { | |
| 304 while ( q.NextRow() ) { | |
| 305 path.Add( q.GetString(0) ); | |
| 306 } | |
| 307 } | |
| 308 stmt.Finalize(); | |
| 309 ccndb.Close(); | |
| 310 | |
| 311 return path; | |
| 312 } | |
| 313 | |
| 314 /* 指定日のパスを取得 */ | |
| 315 wxArrayString GetPathesByDate( wxString date ) | |
| 316 { | |
| 317 wxArrayString path; | |
| 318 | |
| 319 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | |
| 320 wxSQLite3Database ccndb; | |
| 321 ccndb.Open( gszFile ); | |
| 322 | |
| 323 wxSQLite3Statement stmt = ccndb.PrepareStatement( "SELECT path FROM path WHERE date = ?" ); | |
| 324 stmt.Bind( 1, date ); | |
| 300 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | 325 wxSQLite3ResultSet q = stmt.ExecuteQuery(); |
| 301 | 326 |
| 302 if ( !q.IsNull(0) ) { | 327 if ( !q.IsNull(0) ) { |
| 303 while ( q.NextRow() ) { | 328 while ( q.NextRow() ) { |
| 304 path.Add( q.GetString(0) ); | 329 path.Add( q.GetString(0) ); |
