Skip to content

Commit

Permalink
增加查询返回单值api
Browse files Browse the repository at this point in the history
  • Loading branch information
mensong committed Nov 8, 2023
1 parent efbf91b commit 3a67568
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion ConsoleApplicationTest/ConsoleApplicationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
int main()
{
Database* db = SQLit3::Ins().CreateDatabase();
bool b = db->Open("F:\\1.db", "12345678", Database::SQLIT3_OPEN_DEFAULT);
bool b = db->Open("F:\\1.db", "", Database::SQLIT3_OPEN_DEFAULT);
if (!b)
{
std::cout << "打开数据库失败"<< db->GetLastErrorCode()
Expand All @@ -17,6 +17,9 @@ int main()
b = db->Execute("select 1");
//b = db->ResetPassword("12345678");

__int64 maxId = 0;
b = db->QueryInt64("SELECT MAX(id) FROM Url2FileCache", &maxId);

b = db->Execute("CREATE TABLE IF NOT EXISTS \"t1\" (\"a\" TEXT,\"b\" integer,\"c\" real);");
b = db->Execute("INSERT INTO \"main\".\"t1\" (\"a\", \"b\", \"c\") VALUES ('abc', 1, 2.0);");
__int64 changedRow = db->GetChangeRowCount();
Expand Down
12 changes: 6 additions & 6 deletions SQLit3/SQLit3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand All @@ -321,7 +321,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand All @@ -346,7 +346,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand All @@ -371,7 +371,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand Down Expand Up @@ -405,7 +405,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand Down Expand Up @@ -439,7 +439,7 @@ class DatabaseImp
return false;

SqlStatement::ReadStatus status = stmt->Next();
if (status != SqlStatement::SQLIT3_READ_DONE ||
if (status != SqlStatement::SQLIT3_READ_DONE &&
status != SqlStatement::SQLIT3_READ_HAS_ROW)
{
StatementFinalize(stmt);
Expand Down

0 comments on commit 3a67568

Please sign in to comment.