add view project
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "canvas/Circle.hpp"
|
||||
#include "sunShader.hpp"
|
||||
#include "canvas/sunShader.hpp"
|
||||
|
||||
#include <raylib.h>
|
||||
#include <rlgl.h>
|
||||
|
109
shared/src/sql.cpp
Normal file
109
shared/src/sql.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
#include "sql.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
void sql::init()
|
||||
{
|
||||
sqlite3_initialize();
|
||||
sqlite3 *db;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
|
||||
/* Open database */
|
||||
rc = sqlite3_open(DB_NAME, &db);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "Opened database successfully\n");
|
||||
}
|
||||
|
||||
/* Execute SQL statement */
|
||||
rc = sqlite3_exec(db, create_like_table, nullptr, 0, &zErrMsg);
|
||||
if (rc != SQLITE_OK)
|
||||
{
|
||||
fprintf(stderr, "SQL error: %s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "like_table created successfully\n");
|
||||
}
|
||||
|
||||
rc = sqlite3_exec(db, create_user_table, nullptr, 0, &zErrMsg);
|
||||
if (rc != SQLITE_OK)
|
||||
{
|
||||
fprintf(stderr, "SQL error: %s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "user_table created successfully\n");
|
||||
}
|
||||
|
||||
sqlite3_close(db);
|
||||
}
|
||||
|
||||
void sql::shutdown()
|
||||
{
|
||||
sqlite3_shutdown();
|
||||
}
|
||||
|
||||
namespace sql
|
||||
{
|
||||
int open(const char *filename, sqlite3 **ppDb)
|
||||
{
|
||||
return sqlite3_open(filename, ppDb);
|
||||
}
|
||||
int prepare_v2(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **pStmt, const char **pzTail)
|
||||
{
|
||||
return sqlite3_prepare_v2(db, zSql, nByte, pStmt, pzTail);
|
||||
}
|
||||
int bind_int64(sqlite3_stmt *pStmt, int column, int64_t value)
|
||||
{
|
||||
return sqlite3_bind_int64(pStmt, column, value);
|
||||
}
|
||||
int step(sqlite3_stmt *pStmt)
|
||||
{
|
||||
return sqlite3_step(pStmt);
|
||||
}
|
||||
int column_count(sqlite3_stmt *pStmt)
|
||||
{
|
||||
return sqlite3_column_count(pStmt);
|
||||
}
|
||||
int column_type(sqlite3_stmt *pStmt, int column)
|
||||
{
|
||||
return sqlite3_column_type(pStmt, column);
|
||||
}
|
||||
int64_t column_int64(sqlite3_stmt *pStmt, int column)
|
||||
{
|
||||
return sqlite3_column_int64(pStmt, column);
|
||||
}
|
||||
int finalize(sqlite3_stmt *pStmt)
|
||||
{
|
||||
return sqlite3_finalize(pStmt);
|
||||
}
|
||||
int reset(sqlite3_stmt *pStmt)
|
||||
{
|
||||
return sqlite3_reset(pStmt);
|
||||
}
|
||||
int close(sqlite3 *db)
|
||||
{
|
||||
return sqlite3_close(db);
|
||||
}
|
||||
const char *errmsg(sqlite3 *db)
|
||||
{
|
||||
return sqlite3_errmsg(db);
|
||||
}
|
||||
int64_t last_insert_rowid(sqlite3 *db)
|
||||
{
|
||||
return sqlite3_last_insert_rowid(db);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user