這篇文章主要講解了“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”吧!
目前創(chuàng)新互聯(lián)已為上1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁空間、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計(jì)、寒亭網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
一、數(shù)據(jù)庫操作結(jié)果數(shù)據(jù)結(jié)構(gòu)
struct zbx_db_result
{
#if defined(HAVE_IBM_DB2)
SQLHANDLE hstmt;
SQLSMALLINT nalloc;
SQLSMALLINT ncolumn;
DB_ROW values;
DB_ROW values_cli;
SQLINTEGER *values_len;
#elif defined(HAVE_MYSQL)
MYSQL_RES *result;
#elif defined(HAVE_ORACLE)
OCIStmt *stmthp; /* the statement handle for select operations */
int ncolumn;
DB_ROW values;
ub4 *values_alloc;
OCILobLocator **clobs;
#elif defined(HAVE_POSTGRESQL)
PGresult *pg_result;
int row_num;
int fld_num;
int cursor;
DB_ROW values;
#elif defined(HAVE_SQLITE3)
int curow;
char **data;
int nrow;
int ncolumn;
DB_ROW values;
#endif
};
二、數(shù)據(jù)庫根據(jù)sql查詢
/******************************************************************************
* *
* Function: DBselect *
* *
* Purpose: execute a select statement *
* *
* Comments: retry until DB is up *
* *
******************************************************************************/
DB_RESULT __zbx_DBselect(const char *fmt, ...)
{
va_list args; //參數(shù)列表
DB_RESULT rc;
va_start(args, fmt);
rc = zbx_db_vselect(fmt, args);
while ((DB_RESULT)ZBX_DB_DOWN == rc)
{
DBclose();
DBconnect(ZBX_DB_CONNECT_NORMAL);
if ((DB_RESULT)ZBX_DB_DOWN == (rc = zbx_db_vselect(fmt, args)))
{
zabbix_log(LOG_LEVEL_ERR, "database is down: retrying in %d seconds", ZBX_DB_WAIT_DOWN);
connection_failure = 1;
sleep(ZBX_DB_WAIT_DOWN);
}
}
va_end(args);
return rc;
}
三、MySQL操作結(jié)果數(shù)據(jù)結(jié)構(gòu)
typedef struct st_mysql_res {
my_ulonglong row_count;
MYSQL_FIELD *fields;
MYSQL_DATA *data;
MYSQL_ROWS *data_cursor;
unsigned long *lengths; /* column lengths of current row */
MYSQL *handle; /* for unbuffered reads */
const struct st_mysql_methods *methods;
MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */
MEM_ROOT field_alloc;
unsigned int field_count, current_field;
my_bool eof; /* Used by mysql_fetch_row */
/* mysql_stmt_close() had to cancel this result */
my_bool unbuffered_fetch_cancelled;
void *extension;
} MYSQL_RES;
感謝各位的閱讀,以上就是“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!