MCPcopy Create free account
hub / github.com/acl-dev/acl / tbl_exists

Method tbl_exists

lib_acl_cpp/src/db/db_sqlite.cpp:778–809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778bool db_sqlite::tbl_exists(const char* tbl_name)
779{
780 if (tbl_name == NULL || *tbl_name == 0) {
781 logger_error("tbl_name null");
782 return false;
783 }
784
785 acl::string sql;
786 sql.format("select count(*) from sqlite_master"
787 " where type='table' and name='%s'", tbl_name);
788
789 if (!exec_sql(sql.c_str())) {
790 free_result();
791 return false;
792 }
793
794 if (length() == 0) {
795 free_result();
796 return false;
797 } else {
798 const db_row* row = (*this)[0];
799 acl_assert(row != NULL);
800
801 int n = row->field_int((size_t) 0, (int) 0);
802 free_result();
803
804 if (n == 0) {
805 return false;
806 }
807 return true;
808 }
809}
810
811bool db_sqlite::sql_select(const char* sql, db_rows* result /* = NULL */)
812{

Callers

nothing calls this directly

Calls 4

field_intMethod · 0.80
lengthFunction · 0.50
formatMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected