1
0

sql.h 1.1 KB

123456789101112131415161718192021
  1. #ifndef HV_SQL_H_
  2. #define HV_SQL_H_
  3. #include <string>
  4. #include <map>
  5. typedef std::map<std::string, std::string> KeyVal;
  6. // select count(*) from $table_name where $where;
  7. void sql_count(std::string& sql, const char* table_name, const char* where = NULL);
  8. // select $keys from $table_name where $where limit $limit order by $column ASC|DESC;
  9. void sql_select(std::string& sql, const char* table_name, const char* keys = "*", const char* where = NULL, const KeyVal* options = NULL);
  10. // insert into $table_name ($keys) values ($values);
  11. void sql_insert(std::string& sql, const char* table_name, const char* keys, const char* values);
  12. // replace into $table_name ($keys) values ($values);
  13. void sql_replace(std::string& sql, const char* table_name, const char* keys, const char* values);
  14. // update $table_name set $set where $where;
  15. void sql_update(std::string& sql, const char* table_name, const char* set, const char* where = NULL);
  16. // delete from $table_name where $where;
  17. void sql_delete(std::string& sql, const char* table_name, const char* where = NULL);
  18. #endif // HV_SQL_H_