fixed mysql tag to give values for ?# # and field name using #n.
This commit is contained in:
parent
6d2da98024
commit
ae57e06778
@ -24,13 +24,9 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Global::addSession(coreutils::MString sessionId, __mysql *mysql) {
|
void Global::addSession(coreutils::MString sessionId, __mysql *mysql) {
|
||||||
std::cout << "sessionId: " << sessionId << std::endl;
|
|
||||||
if(sessionExists(sessionId))
|
if(sessionExists(sessionId))
|
||||||
coreutils::Exception("sessionid already exists.");
|
coreutils::Exception("sessionid already exists.");
|
||||||
sessions[sessionId] = mysql;
|
sessions[sessionId] = mysql;
|
||||||
|
|
||||||
std::cout << "::count: " << sessions.size() << std::endl;
|
|
||||||
std::cout << "::" << sessionId << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Global::removeSession(coreutils::MString sessionId) {
|
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) {
|
void Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map<coreutils::MString, coreutils::MString> &lvariables) {
|
||||||
while(!variable.ifNext("]")) {
|
while(!variable.ifNext("]")) {
|
||||||
name << variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
name << variable.getTokenInclude("#?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||||
if(variable.ifNext(";")) {
|
if(variable.ifNext(";")) {
|
||||||
renderVariableName(variable, modifier, modifier, lvariables);
|
renderVariableName(variable, modifier, modifier, lvariables);
|
||||||
return;
|
return;
|
||||||
@ -111,7 +107,7 @@ namespace jet {
|
|||||||
name << getVariable(variable, lvariables);
|
name << getVariable(variable, lvariables);
|
||||||
else if(variable.ifNext("]"))
|
else if(variable.ifNext("]"))
|
||||||
return;
|
return;
|
||||||
else if(!variable.ifNextInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
|
else if(!variable.ifNextInclude("#?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
|
||||||
throw coreutils::Exception("invalid variable name.");
|
throw coreutils::Exception("invalid variable name.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
10
__for.cpp
10
__for.cpp
@ -23,8 +23,14 @@ namespace jet {
|
|||||||
for(double ix = counter; ix <= variables["end"].asDouble(); ix += variables["step"].asDouble()) {
|
for(double ix = counter; ix <= variables["end"].asDouble(); ix += variables["step"].asDouble()) {
|
||||||
variables["end"].reset();
|
variables["end"].reset();
|
||||||
variables["step"].reset();
|
variables["step"].reset();
|
||||||
if(nameDefined)
|
if(nameDefined) {
|
||||||
variables[variables["name"]] = ix;
|
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);
|
processContainer(container);
|
||||||
container.reset();
|
container.reset();
|
||||||
}
|
}
|
||||||
|
20
__mysql.cpp
20
__mysql.cpp
@ -31,8 +31,6 @@ namespace jet {
|
|||||||
if(!mysql)
|
if(!mysql)
|
||||||
throw coreutils::Exception("database and host parameters are not valid.");
|
throw coreutils::Exception("database and host parameters are not valid.");
|
||||||
|
|
||||||
std::cout << "mysql: " << mysql << std::endl;
|
|
||||||
|
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -63,9 +61,23 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
coreutils::ZString __mysql::getColumnValue(coreutils::ZString column) {
|
coreutils::ZString __mysql::getColumnValue(coreutils::ZString column) {
|
||||||
if(column == "#")
|
|
||||||
return NbrOfRows;
|
|
||||||
MYSQL_FIELD *field;
|
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) {
|
for(int ix = 0; ix < qFields; ++ix) {
|
||||||
field = mysql_fetch_field_direct(result, ix);
|
field = mysql_fetch_field_direct(result, ix);
|
||||||
if(column.equals((char *)field->name)) {
|
if(column.equals((char *)field->name)) {
|
||||||
|
@ -28,7 +28,8 @@ namespace jet {
|
|||||||
unsigned int qFields;
|
unsigned int qFields;
|
||||||
coreutils::MString sessionId;
|
coreutils::MString sessionId;
|
||||||
|
|
||||||
coreutils::MString NbrOfRows = "0";
|
coreutils::MString nbrOfRows = "0";
|
||||||
|
coreutils::MString nbrOfColumns = "0";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,5 +5,10 @@
|
|||||||
<whilerow name="index" count="10" sessionid="1">
|
<whilerow name="index" count="10" sessionid="1">
|
||||||
$[1.id] $[1.text] $[1.value]
|
$[1.id] $[1.text] $[1.value]
|
||||||
</whilerow>
|
</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>
|
</mysql>
|
||||||
</jet>
|
</jet>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user