fixed mysql tag to give values for ?# # and field name using #n.

This commit is contained in:
brad Arant 2024-11-27 15:37:58 -08:00
parent 6d2da98024
commit ae57e06778
5 changed files with 33 additions and 13 deletions

View File

@ -24,13 +24,9 @@ namespace jet {
}
void Global::addSession(coreutils::MString sessionId, __mysql *mysql) {
std::cout << "sessionId: " << sessionId << std::endl;
if(sessionExists(sessionId))
coreutils::Exception("sessionid already exists.");
sessions[sessionId] = mysql;
std::cout << "::count: " << sessions.size() << std::endl;
std::cout << "::" << sessionId << std::endl;
}
void Global::removeSession(coreutils::MString sessionId) {
@ -101,7 +97,7 @@ namespace jet {
void Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map<coreutils::MString, coreutils::MString> &lvariables) {
while(!variable.ifNext("]")) {
name << variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
name << variable.getTokenInclude("#?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(variable.ifNext(";")) {
renderVariableName(variable, modifier, modifier, lvariables);
return;
@ -111,7 +107,7 @@ namespace jet {
name << getVariable(variable, lvariables);
else if(variable.ifNext("]"))
return;
else if(!variable.ifNextInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
else if(!variable.ifNextInclude("#?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
throw coreutils::Exception("invalid variable name.");
}
return;

View File

@ -23,8 +23,14 @@ namespace jet {
for(double ix = counter; ix <= variables["end"].asDouble(); ix += variables["step"].asDouble()) {
variables["end"].reset();
variables["step"].reset();
if(nameDefined)
variables[variables["name"]] = ix;
if(nameDefined) {
if(!variableDefined("scope") || (variables["scope"] == "global"))
global.variables[variables["name"]] = ix;
else if(variables["scope"] == "local")
local->variables[variables["name"]] = ix;
else if(variables["scope"] == "parent")
parent->local->variables[variables["name"]] = ix;
}
processContainer(container);
container.reset();
}

View File

@ -30,8 +30,6 @@ namespace jet {
if(!mysql)
throw coreutils::Exception("database and host parameters are not valid.");
std::cout << "mysql: " << mysql << std::endl;
processContainer(container);
@ -63,9 +61,23 @@ namespace jet {
}
coreutils::ZString __mysql::getColumnValue(coreutils::ZString column) {
if(column == "#")
return NbrOfRows;
MYSQL_FIELD *field;
if(column == "?#") {
nbrOfColumns = (int)qFields;
return nbrOfColumns;
} else if(column.ifNext("#")) {
if(column.eod()) {
nbrOfRows = (int)mysql_num_rows(result);
return nbrOfRows;
} else {
std::cout << "[" << column.unparsed() << "]" << std::endl;
int index = column.asInteger();
std::cout << "integer: " << index << std::endl;
field = mysql_fetch_field_direct(result, index - 1);
return coreutils::ZString(field->name);
}
}
for(int ix = 0; ix < qFields; ++ix) {
field = mysql_fetch_field_direct(result, ix);
if(column.equals((char *)field->name)) {

View File

@ -28,7 +28,8 @@ namespace jet {
unsigned int qFields;
coreutils::MString sessionId;
coreutils::MString NbrOfRows = "0";
coreutils::MString nbrOfRows = "0";
coreutils::MString nbrOfColumns = "0";
};

View File

@ -5,5 +5,10 @@
<whilerow name="index" count="10" sessionid="1">
$[1.id] $[1.text] $[1.value]
</whilerow>
Number of rows: $[1.#]
Number of columns: $[1.?#]
<for name="ix" start="1" end="$[1.?#]" step="1">
Field $[ix] is $[1.#$[ix]]
</for>
</mysql>
</jet>