@MySQLGetNumRows
Syntax
@MySQLGetNumRows(MySQLResultHandle);
@MySQLGetNumRows(MySQLPreparedStatementHandle);
Description
Returns the number of rows of a stored result of a @MySQLQuery or @MySQLExecutePreparedStatement query.
Return:
On success FN Count, otherwise @Error;
Example: @MySQLGetNumRows(MySQLResultHandle);
MySQLh:=@MySQLInit;
MySQLError:=1;
IF(@IsError(MySQLh)){
@LogReport(MySQLh;3);
}ELSE{
@MySQLOptions(MySQLh);
MySQLUser:="MySQLConnectorUser";
MySQLPassword:="ConnectorPassword";
MySQLDefaultDatabase:="testdb";
MySQLHost:="mysql.intranet";
Ret:=@MySQLConnect(MySQLh;MySQLHost;MySQLUser;MySQLPassword;MySQLDefaultDatabase);
IF(@IsError(Ret)){
@LogReport(Ret);
}ELSE{
MySQLError:=0;}
IF(!MySQLError){
QueryStr:="SELECT ID,Name,Amount,UID FROM testdb.amounts WHERE Name=\"Test User\";";
Ret:=@MySQLQuery(MySQLh;QueryStr;MySQLResH);
NumRows:=@MySQLGetNumRows(MySQLResH);
IF(NumRows=1){
Ret:=@MySQLFetchRow(MySQLResH;1;ThisQueryID;ThisQueryName;ThisQueryAmount;ThisQueryUID);
}ELSE{
ThisQueryID:=-1;
ThisQueryAmount:=0;
ThisQueryName:=ThisQueryUID:="";
}
MySQLResH:=@MySQLFreeResult(MySQLResH);
@LogReport("ThisQueryID :"+@Text(ThisQueryID);3);
@LogReport("ThisQueryName :"+ThisQueryName;3);
@LogReport("ThisQueryAmount:"+@Text(ThisQueryAmount);3);
@LogReport("ThisQueryUID :"+ThisQueryUID;3);
}
MySQLh:=@MySQLClose(MySQLh);
}
@MySQLThreadEnd;
MySQL DB for this example:
INSERT INTO testdb.amount (Name,Amount,UID,ModTime) VALUES ("Test User",123.45,"1234567890ABCDEFABCD1234567890AB",NOW());
Output in APILOG for this example:
NumRows:1
ThisQueryID :1
ThisQueryName :Test User
ThisQueryAmount:123.45
ThisQueryUID :1234567890ABCDEFABCD1234567890AB
A MySQL connection is established and a query is submitted; the result is then output to APILOG.
Note : This text was machine-translated and may contain inaccuracies.
