本文整理汇总了C++中CON_TABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ CON_TABLE函数的具体用法?C++ CON_TABLE怎么用?C++ CON_TABLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CON_TABLE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: flat_use_table
/*
* Store name of table that will be used by
* subsequent database functions
*/
int flat_use_table(db1_con_t* h, const str* t)
{
struct flat_con* con;
if (!h || !t || !t->s) {
LM_ERR("invalid parameter value\n");
return -1;
}
if (CON_TABLE(h)->s != t->s) {
if (CON_TAIL(h)) {
/* Decrement the reference count
* of the connection but do not remove
* it from the connection pool
*/
con = (struct flat_con*)CON_TAIL(h);
con->ref--;
}
CON_TAIL(h) = (unsigned long)
flat_get_connection((char*)CON_TABLE(h)->s, (char*)t->s);
if (!CON_TAIL(h)) {
return -1;
}
}
return 0;
}
开发者ID:SibghatullahSheikh,项目名称:kamailio,代码行数:32,代码来源:km_flatstore.c
示例2: db_query
/*
* Query table for specified rows
* _h: structure representing database connection
* _k: key names
* _op: operators
* _v: values of the keys that must match
* _c: column names to return
* _n: nmber of key=values pairs to compare
* _nc: number of columns to return
* _o: order by the specified column
*/
int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
db_val_t* _v, db_key_t* _c, int _n, int _nc,
db_key_t _o, db_res_t** _r)
{
int off, rv;
if (!_c) {
off = snprintf(sql_buf, SQL_BUF_LEN,
"select * from %s ", CON_TABLE(_h));
} else {
off = snprintf(sql_buf, SQL_BUF_LEN, "select ");
off += print_columns(sql_buf + off, SQL_BUF_LEN - off, _c, _nc);
off += snprintf(sql_buf + off, SQL_BUF_LEN - off,
"from %s ", CON_TABLE(_h));
}
if (_n) {
off += snprintf(sql_buf + off, SQL_BUF_LEN - off, "where ");
off += print_where(sql_buf + off, SQL_BUF_LEN - off,
_k, _op, _v, _n);
}
if (_o) {
off += snprintf(sql_buf + off, SQL_BUF_LEN - off,
"order by %s", _o);
}
if(begin_transaction(_h, sql_buf)) return(-1);
if (submit_query(_h, sql_buf) < 0) {
LOG(L_ERR, "db_query(): Error while submitting query\n");
return -2;
}
rv = get_result(_h, _r);
free_query(_h);
commit_transaction(_h);
return(rv);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:45,代码来源:dbase.c
示例3: erlang_srdb1_insert_update
/**
* Insert a row into a specified table, update on duplicate key.
* \param _h structure representing database connection
* \param _k key names
* \param _v values of the keys
* \param _n number of key=value pairs
*/
int erlang_srdb1_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
const int _n)
{
ei_x_buff argbuf;
int retcode;
if ((!_h) || (!_k) || (!_v) || (!_n)) {
LM_ERR("invalid parameter value\n");
return -1;
}
LM_DBG("erlang_srdb1_insert_update table %.*s\n",CON_TABLE(_h)->len, CON_TABLE(_h)->s);
ei_x_new(&argbuf);
//encode tuple {db_op, table, [cols], [keys], [vals]}
ei_x_encode_tuple_header(&argbuf, 5);
ei_x_encode_atom(&argbuf,"insert_update");
ei_x_encode_atom_len(&argbuf,CON_TABLE(_h)->s,CON_TABLE(_h)->len);
ei_x_encode_list_header(&argbuf, 0); //_c
// ei_x_encode_list_header(&argbuf, 0); //_k
srdb1_encode_k(_k, NULL, _v, _n, &argbuf); //_k
srdb1_encode_v(_k, _v, _n, &argbuf); //_v
retcode=erl_bind.do_erlang_call(&(CON_ERLANG(_h)->con),&(CON_ERLANG(_h)->regname), &argbuf, NULL /*&retbuf*/);
ei_x_free(&argbuf);
if (retcode<0) {
// if(retbuf.buff) shm_free(retbuf.buff);
return retcode;
}
return 0;
}
开发者ID:majastanislawska,项目名称:sip-router-erlang-module,代码行数:37,代码来源:db_erlang_srdb1.c
示例4: db_mysql_query
/*
* Query table for specified rows
* _h: structure representing database connection
* _k: key names
* _op: operators
* _v: values of the keys that must match
* _c: column names to return
* _n: number of key=values pairs to compare
* _nc: number of columns to return
* _o: order by the specified column
*/
int db_mysql_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
db_val_t* _v, db_key_t* _c, int _n, int _nc,
db_key_t _o, db_res_t** _r)
{
int off, ret;
if (!_h) {
LM_ERR("invalid parameter value\n");
return -1;
}
if (!_c) {
ret = snprintf(sql_buf, SQL_BUF_LEN, "select * from %s ", CON_TABLE(_h));
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
} else {
ret = snprintf(sql_buf, SQL_BUF_LEN, "select ");
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
ret = db_print_columns(sql_buf + off, SQL_BUF_LEN - off, _c, _nc);
if (ret < 0) return -1;
off += ret;
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, "from %s ", CON_TABLE(_h));
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
}
if (_n) {
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, "where ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_where(_h, sql_buf + off,
SQL_BUF_LEN - off, _k, _op, _v, _n, val2str);
if (ret < 0) return -1;;
off += ret;
}
if (_o) {
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " order by %s", _o);
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
}
*(sql_buf + off) = '\0';
if (db_mysql_submit_query(_h, sql_buf) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
if(_r)
return db_mysql_store_result(_h, _r);
return 0;
error:
LM_ERR("error in snprintf\n");
return -1;
}
开发者ID:eliasbaixas,项目名称:openser-xmlrpc,代码行数:70,代码来源:dbase.c
示例5: db_do_delete
int db_do_delete( db_con_t* _h, db_key_t* _k, db_op_t* _o,
db_val_t* _v, int _n, int (*val2str) ( db_con_t*,
db_val_t*, char*, int*), int (*submit_query)( db_con_t* _h,
str* _c),str *query_holder)
{
int off, ret;
str sql_str;
char sql_buf[SQL_BUF_LEN];
if (!_h || !val2str || (!submit_query && !query_holder)) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "delete from %.*s", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
if (_n) {
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " where ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_where(_h, sql_buf + off,
SQL_BUF_LEN - off, _k, _o, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
}
if (off + 1 > SQL_BUF_LEN) goto error;
sql_buf[off] = '\0';
sql_str.s = sql_buf;
sql_str.len = off;
if (submit_query)
{
if (submit_query(_h, &sql_str) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
}
else
{
query_holder->s = pkg_malloc(off);
if (!query_holder->s)
{
LM_ERR("no more pkg mem\n");
return -2;
}
memcpy(query_holder->s,sql_buf,off);
query_holder->len = off;
}
return 0;
error:
LM_ERR("error while preparing delete operation\n");
return -1;
}
开发者ID:AbedKarmi,项目名称:opensips-ng,代码行数:57,代码来源:db_query.c
示例6: db_insert_update
/**
* Insert a row into a specified table, update on duplicate key.
* \param _h structure representing database connection
* \param _k key names
* \param _v values of the keys
* \param _n number of key=value pairs
*/
int db_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
const int _n)
{
int off, ret;
static str sql_str;
static char sql_buf[SQL_BUF_LEN];
if ((!_h) || (!_k) || (!_v) || (!_n)) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "insert into %.*s (", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
ret = db_print_columns(sql_buf + off, SQL_BUF_LEN - off, _k, _n);
if (ret < 0) return -1;
off += ret;
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, ") values (");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_values(_h, sql_buf + off, SQL_BUF_LEN - off, _v, _n, db_mysql_val2str);
if (ret < 0) return -1;
off += ret;
*(sql_buf + off++) = ')';
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " on duplicate key update ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_set(_h, sql_buf + off, SQL_BUF_LEN - off, _k, _v, _n, db_mysql_val2str);
if (ret < 0) return -1;
off += ret;
sql_str.s = sql_buf;
sql_str.len = off;
if (db_mysql_submit_query(_h, &sql_str) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error while preparing insert_update operation\n");
return -1;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:57,代码来源:km_dbase.c
示例7: db_do_update
int db_do_update(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o,
const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
const int _un, int (*val2str) (const db_con_t*, const db_val_t*, char*, int*),
int (*submit_query)(const db_con_t* _h, const str* _c))
{
int off, ret;
if (!_h || !_uk || !_uv || !_un || !val2str || !submit_query) {
LM_ERR("invalid parameter value\n");
goto err_exit;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "update %.*s set ", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
ret = db_print_set(_h, sql_buf + off, SQL_BUF_LEN - off, _uk, _uv, _un, val2str);
if (ret < 0) goto err_exit;
off += ret;
if (_n) {
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " where ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_where(_h, sql_buf + off, SQL_BUF_LEN - off, _k, _o, _v, _n, val2str);
if (ret < 0) goto err_exit;
off += ret;
}
if (off + 1 > SQL_BUF_LEN) goto error;
sql_buf[off] = '\0';
sql_str.s = sql_buf;
sql_str.len = off;
if (submit_query(_h, &sql_str) < 0) {
LM_ERR("error while submitting query\n");
CON_OR_RESET(_h);
return -2;
}
CON_OR_RESET(_h);
return 0;
error:
LM_ERR("error while preparing update operation\n");
err_exit:
CON_OR_RESET(_h);
return -1;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:49,代码来源:db_query.c
示例8: db_do_insert_cmd
int db_do_insert_cmd(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
const int _n, int (*val2str) (const db1_con_t*, const db_val_t*, char*, int*),
int (*submit_query)(const db1_con_t* _h, const str* _c), int mode)
{
int off, ret;
if (!_h || !_k || !_v || !_n || !val2str || !submit_query) {
LM_ERR("invalid parameter value\n");
return -1;
}
if(mode==1)
ret = snprintf(sql_buf, sql_buffer_size, "insert delayed into %s%.*s%s (",
CON_TQUOTESZ(_h), CON_TABLE(_h)->len, CON_TABLE(_h)->s, CON_TQUOTESZ(_h));
else
ret = snprintf(sql_buf, sql_buffer_size, "insert into %s%.*s%s (",
CON_TQUOTESZ(_h), CON_TABLE(_h)->len, CON_TABLE(_h)->s, CON_TQUOTESZ(_h));
if (ret < 0 || ret >= sql_buffer_size) goto error;
off = ret;
ret = db_print_columns(sql_buf + off, sql_buffer_size - off, _k, _n, CON_TQUOTESZ(_h));
if (ret < 0) return -1;
off += ret;
ret = snprintf(sql_buf + off, sql_buffer_size - off, ") values (");
if (ret < 0 || ret >= (sql_buffer_size - off)) goto error;
off += ret;
ret = db_print_values(_h, sql_buf + off, sql_buffer_size - off, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
if (off + 2 > sql_buffer_size) goto error;
sql_buf[off++] = ')';
sql_buf[off] = '\0';
sql_str.s = sql_buf;
sql_str.len = off;
if (db_do_submit_query(_h, &sql_str, submit_query) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error while preparing insert operation\n");
return -1;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:48,代码来源:db_query.c
示例9: db_oracle_update
/*
* Update some rows in the specified table
* _h: structure representing database connection
* _k: key names
* _o: operators
* _v: values of the keys that must match
* _uk: updated columns
* _uv: updated values of the columns
* _n: number of key=value pairs
* _un: number of columns to update
*/
int db_oracle_update(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o,
const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv,
int _n, int _un)
{
query_data_t cb;
int rc;
if (!_h || !CON_TABLE(_h)) {
LM_ERR("invalid parameter value\n");
return -1;
}
cb._rs = NULL;
cb._v = _uv;
cb._n = _un;
cb._w = _v;
cb._nw = _n;
CON_ORA(_h)->pqdata = &cb;
CON_ORA(_h)->bindpos = 0;
CON_RESET_CURR_PS(_h); /* no prepared statements support */
rc = db_do_update(_h, _k, _o, _v, _uk, _uv, _n, _un,
db_oracle_val2str, db_oracle_submit_query);
CON_ORA(_h)->pqdata = NULL; /* paranoid for next call */
return rc;
}
开发者ID:dynamicpacket-public,项目名称:opensips17,代码行数:36,代码来源:dbase.c
示例10: db_mysql_delete
/*
* Delete a row from the specified table
* _h: structure representing database connection
* _k: key names
* _o: operators
* _v: values of the keys that must match
* _n: number of key=value pairs
*/
int db_mysql_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
{
int off, ret;
if (!_h) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "delete from %s", CON_TABLE(_h));
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
if (_n) {
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " where ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_where(_h, sql_buf + off,
SQL_BUF_LEN - off, _k, _o, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
}
*(sql_buf + off) = '\0';
if (db_mysql_submit_query(_h, sql_buf) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error in snprintf\n");
return -1;
}
开发者ID:eliasbaixas,项目名称:openser-xmlrpc,代码行数:43,代码来源:dbase.c
示例11: db_oracle_query
/*
* Query table for specified rows
* _h: structure representing database connection
* _k: key names
* _op: operators
* _v: values of the keys that must match
* _c: column names to return
* _n: number of key=values pairs to compare
* _nc: number of columns to return
* _o: order by the specified column
*/
int db_oracle_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
const db_val_t* _v, const db_key_t* _c, int _n, int _nc,
const db_key_t _o, db1_res_t** _r)
{
query_data_t cb;
OCIStmt* reshp;
int rc;
if (!_h || !CON_TABLE(_h) || !_r) {
LM_ERR("invalid parameter value\n");
return -1;
}
cb._rs = &reshp;
cb._v = _v;
cb._n = _n;
cb._w = NULL;
cb._nw = 0;
CON_ORA(_h)->pqdata = &cb;
CON_ORA(_h)->bindpos = 0;
rc = db_do_query(_h, _k, _op, _v, _c, _n, _nc, _o, _r,
db_oracle_val2str, db_oracle_submit_query, db_oracle_store_result);
CON_ORA(_h)->pqdata = NULL; /* paranoid for next call */
return rc;
}
开发者ID:SibghatullahSheikh,项目名称:kamailio,代码行数:36,代码来源:dbase.c
示例12: flat_use_table
/*
* Store name of table that will be used by
* subsequent database functions
*/
int flat_use_table(db_con_t* h, const str* t)
{
struct flat_con* con;
if (!h || !t || !t->s) {
LM_ERR("invalid parameter value\n");
return -1;
}
if (!CON_TAIL(h) || !(CON_FILENAME(h).len == t->len &&
!memcmp(CON_FILENAME(h).s, t->s, t->len))) {
if (CON_TAIL(h)) {
/* Decrement the reference count
* of the connection but do not remove
* it from the connection pool
*/
con = (struct flat_con*)CON_TAIL(h);
con->ref--;
}
CON_TAIL(h) = (unsigned long)
flat_get_connection(CON_TABLE(h), t);
if (!CON_TAIL(h)) {
return -1;
}
}
return 0;
}
开发者ID:OpenSIPS,项目名称:opensips,代码行数:33,代码来源:flatstore.c
示例13: bdb_use_table
int bdb_use_table(db_con_t* _h, const char* _t)
{
if ((!_h) || (!_t))
return -1;
CON_TABLE(_h) = _t;
return 0;
}
开发者ID:eliasbaixas,项目名称:openser-xmlrpc,代码行数:8,代码来源:db_berkeley.c
示例14: db_do_replace
int db_do_replace( db_con_t* _h, db_key_t* _k, db_val_t* _v,
int _n, int (*val2str) ( db_con_t*, db_val_t*, char*,
int*), int (*submit_query)( db_con_t* _h, str* _c))
{
int off, ret;
str sql_str;
char sql_buf[SQL_BUF_LEN];
if (!_h || !_k || !_v || !val2str|| !submit_query) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "replace %.*s (", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
ret = db_print_columns(sql_buf + off, SQL_BUF_LEN - off, _k, _n);
if (ret < 0) return -1;
off += ret;
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, ") values (");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_values(_h, sql_buf + off, SQL_BUF_LEN - off, _v, _n,
val2str);
if (ret < 0) return -1;
off += ret;
if (off + 2 > SQL_BUF_LEN) goto error;
sql_buf[off++] = ')';
sql_buf[off] = '\0';
sql_str.s = sql_buf;
sql_str.len = off;
if (submit_query(_h, &sql_str) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error while preparing replace operation\n");
return -1;
}
开发者ID:AbedKarmi,项目名称:opensips-ng,代码行数:46,代码来源:db_query.c
示例15: db_do_update
int db_do_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
const int _un, int (*val2str) (const db1_con_t*, const db_val_t*, char*, int*),
int (*submit_query)(const db1_con_t* _h, const str* _c))
{
int off, ret;
if (!_h || !_uk || !_uv || !_un || !val2str || !submit_query) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, sql_buffer_size, "update %s%.*s%s set ",
CON_TQUOTESZ(_h), CON_TABLE(_h)->len, CON_TABLE(_h)->s, CON_TQUOTESZ(_h));
if (ret < 0 || ret >= sql_buffer_size) goto error;
off = ret;
ret = db_print_set(_h, sql_buf + off, sql_buffer_size - off, _uk, _uv, _un, val2str);
if (ret < 0) return -1;
off += ret;
if (_n) {
ret = snprintf(sql_buf + off, sql_buffer_size - off, " where ");
if (ret < 0 || ret >= (sql_buffer_size - off)) goto error;
off += ret;
ret = db_print_where(_h, sql_buf + off, sql_buffer_size - off, _k, _o, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
}
if (off + 1 > sql_buffer_size) goto error;
sql_buf[off] = '\0';
sql_str.s = sql_buf;
sql_str.len = off;
if (db_do_submit_query(_h, &sql_str, submit_query) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error while preparing update operation\n");
return -1;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:45,代码来源:db_query.c
示例16: dbt_affected_rows
/*
* Affected Rows
*/
int dbt_affected_rows(db1_con_t* _h)
{
if (!_h || !CON_TABLE(_h))
{
LM_ERR("invalid parameter\n");
return -1;
}
return ((dbt_con_p)_h->tail)->affected;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:13,代码来源:dbt_base.c
示例17: bdb_rrow_db2bdb
int bdb_rrow_db2bdb(db_con_t* _h, db_key_t* _k, int _n, bdb_rrow_p *_r)
{
bdb_rrow_p r;
bdb_table_p t;
bdb_column_p c;
int found;
int i;
int c_idx;
*_r = NULL;
if ((t = bdb_find_table(CON_TABLE(_h))) == NULL) {
#ifdef BDB_EXTRA_DEBUG
LOG(L_ERR, "BDB:bdb_rrow_db2bdb: no table in use\n");
#endif
return -1;
};
i = (_n == 0) ? BDB_CON_COL_NUM(_h) : _n;
r = pkg_malloc(sizeof(*r) * i);
memset(r, 0, sizeof(*r) * i);
if (_n > 0) {
for (i = 0; i < _n; i++) {
found = 0;
for (c = t->cols, c_idx = 0; c != NULL; c = c->next, c_idx++) {
if (!strcmp(_k[i], c->name.s)) {
#ifdef BDB_EXTRA_DEBUG
LOG(L_NOTICE, "BDB:bdb_rrow_db2bdb: filling column '%.*s', c_idx = %0d\n", c->name.len, c->name.s, c_idx);
#endif
r[i] = c_idx;
found = 1;
break;
}
}
if (!found) {
LOG(L_ERR, "BDB:bdb_rrow_db2bdb: column '%s' does not exist\n", _k[i]);
bdb_free_rrow(r);
return -1;
}
}
} else { /* return all columns */
for (c = t->cols, c_idx = 0; c != NULL; c = c->next, c_idx++) {
#ifdef BDB_EXTRA_DEBUG
LOG(L_NOTICE, "BDB:bdb_rrow_db2bdb: filling column '%.*s', c_idx = %0d\n", c->name.len, c->name.s, c_idx);
#endif
r[c_idx] = c_idx;
}
}
*_r = r;
return 0;
};
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:55,代码来源:bdb_rval.c
示例18: use_table
/*
* Store name of table that will be used by
* subsequent database functions
*/
int use_table(db_con_t* _h, const char* _t)
{
char* ptr;
int l;
#ifdef PARANOID
if ((!_h) || (!_t)) {
LOG(L_ERR, "use_table(): Invalid parameter value\n");
return -1;
}
#endif
l = strlen(_t) + 1;
ptr = (char*)pkg_malloc(l);
if (!ptr) {
LOG(L_ERR, "use_table(): No memory left\n");
return -2;
}
memcpy(ptr, _t, l);
if (CON_TABLE(_h)) pkg_free(CON_TABLE(_h));
CON_TABLE(_h) = ptr;
return 0;
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:26,代码来源:db_con.c
示例19: dbt_use_table
int dbt_use_table(db_con_t* _h, const char* _t)
{
if ((!_h) || (!_t))
{
#ifdef DBT_EXTRA_DEBUG
LOG(L_ERR, "DBT:dbt_use_table: Invalid parameter value\n");
#endif
return -1;
}
CON_TABLE(_h) = _t;
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:14,代码来源:dbt_api.c
示例20: db_insert_update
/*
* Insert a row into specified table, update on duplicate key
* _h: structure representing database connection
* _k: key names
* _v: values of the keys
* _n: number of key=value pairs
*/
int db_insert_update(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
{
int off, ret;
if ((!_h) || (!_k) || (!_v) || (!_n)) {
LM_ERR("invalid parameter value\n");
return -1;
}
ret = snprintf(sql_buf, SQL_BUF_LEN, "insert into %s (", CON_TABLE(_h));
if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
off = ret;
ret = db_print_columns(sql_buf + off, SQL_BUF_LEN - off, _k, _n);
if (ret < 0) return -1;
off += ret;
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, ") values (");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_values(_h, sql_buf + off, SQL_BUF_LEN - off, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
*(sql_buf + off++) = ')';
ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " ON DUPLICATE KEY UPDATE ");
if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error;
off += ret;
ret = db_print_set(_h, sql_buf + off, SQL_BUF_LEN - off, _k, _v, _n, val2str);
if (ret < 0) return -1;
off += ret;
*(sql_buf + off) = '\0';
if (db_mysql_submit_query(_h, sql_buf) < 0) {
LM_ERR("error while submitting query\n");
return -2;
}
return 0;
error:
LM_ERR("error in snprintf\n");
return -1;
}
开发者ID:eliasbaixas,项目名称:openser-xmlrpc,代码行数:53,代码来源:dbase.c
注:本文中的CON_TABLE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论