本文整理汇总了C++中TeDatabasePortal::numRows方法的典型用法代码示例。如果您正苦于以下问题:C++ TeDatabasePortal::numRows方法的具体用法?C++ TeDatabasePortal::numRows怎么用?C++ TeDatabasePortal::numRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TeDatabasePortal
的用法示例。
在下文中一共展示了TeDatabasePortal::numRows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPermissions
SEXP aRTconn::GetPermissions(SEXP data)
{
SEXP result;
SEXP *each_column;
SEXP colnames;
SEXP rownames;
string query;
string user = GET_STRING_ELEMENT(data, "user" );
bool global = GET_BOOL_ELEMENT (data, "global");
TeDatabase* db = NewTeDatabase();
if( !db -> connect(Host, User, Password, "", Port))
error("Could not connect\n");
TeDatabasePortal* portal = db->getPortal();
if(global)
query = "select Host,User,Password,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv from mysql.user";
else
query = "select Host,User,Db,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv from mysql.db";
if(user != "")
{
query += " where user= \"";
query += user;
query += "\";";
}
else
{
query += ";";
}
portal->query(query);
each_column = new SEXP[8];
colnames = PROTECT(allocVector( STRSXP, 8 ));
result = PROTECT(allocVector( VECSXP, 8 ));
rownames = PROTECT(allocVector( STRSXP, portal->numRows() ));
for(int i = 0; i < 8; i++)
each_column[i] = PROTECT(allocVector( STRSXP, portal->numRows() ));
SET_STRING_ELT(colnames, 0, mkChar("host" ));
SET_STRING_ELT(colnames, 1, mkChar("user" ));
SET_STRING_ELT(colnames, 2, mkChar(global? "password": "db"));
SET_STRING_ELT(colnames, 3, mkChar("select" ));
SET_STRING_ELT(colnames, 4, mkChar("insert" ));
SET_STRING_ELT(colnames, 5, mkChar("update" ));
SET_STRING_ELT(colnames, 6, mkChar("delete" ));
SET_STRING_ELT(colnames, 7, mkChar("create" ));
for(int i = 0; i != portal->numRows(); i++)
{
portal->fetchRow();
string host = portal->getData(0);
if(host == "%") host = "<any>";
SET_STRING_ELT( each_column[0], i, mkChar(host.c_str()) );
// user
SET_STRING_ELT( each_column[1], i, mkChar(portal->getData(1)) );
if(global)
{
string password = portal->getData(2);
password = password == ""? "No" : "Yes";
SET_STRING_ELT( each_column[2], i, mkChar(password.c_str()) );
}
else
{
string db = portal->getData(2);
SET_STRING_ELT( each_column[2], i, mkChar(db.c_str()) );
}
for(unsigned j = 3; j != 8; j++)
{
string value = portal->getData(j);
if(value == "Y") value = "Yes";
if(value == "N") value = "No";
SET_STRING_ELT( each_column[j], i, mkChar(value.c_str()) );
}
stringstream str;
str << i+1; // rownames must start from 1
SET_STRING_ELT(rownames, i, mkChar(str.str().c_str()));
}
setAttrib(result, R_NamesSymbol, colnames);
for(unsigned j = 0; j != 8; j++)
SET_VECTOR_ELT(result, j, each_column[j]);
result = AsDataFrame(result, rownames);
UNPROTECT(11);
delete[] each_column;
delete db;
//.........这里部分代码省略.........