数据库中的记录是这样的:
id name priv
1 ss 2
1 aa 3
1 ff 1
1 gg 4
我要发送的内容是:1,ss,2,3,1,4
主函数是// 根据 id 取权限的回调
int cb_get_priv void *cb_data, int col_num, char *col_value[], char *col_name[] )
{
int len;
char *Priv = (char *)cb_data;
len = strlen( Privilege );
if( len != 0 )
{
Priv[len++] = ',';
}
strcpy( Priv + len, col_value[0] );
return 0;
}
// 根据 id 取权限
int get_priv( int id, char *priv)
{
char sql[128];
sprintf( sql, "select priv from user where id=%d", id );
if( db_exec_sql( m_pdb, sql, cb_get_priv, priv ) < 0 )
{
return -1;
}
return 0;
}
阅读(2647) | 评论(0) | 转发(0) |