Working on whilerow.

This commit is contained in:
brad Arant 2024-09-25 20:10:19 -07:00
parent 9977ca188c
commit a09e370e57
3 changed files with 55 additions and 1 deletions

33
__whilerow.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "__whilerow.h"
#include "Exception.h"
#include <iostream>
namespace jet {
__whilerow::__whilerow(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
if(!variableDefined("host"))
throw coreutils::Exception("host must be specified for mysql tag.");
if(!variableDefined("database"))
throw coreutils::Exception("database must be specified for mysql tag.");
if(!variableDefined("user"))
throw coreutils::Exception("user must be specified for mysql tag.");
if(!variableDefined("password"))
throw coreutils::Exception("password must be specified for mysql tag.");
while ((count != 0) && sql[sqlsession].row) {
processContainer(container);
sql[sqlsession].row = mysql_fetch_row (sql[sqlsession].result);
sql[sqlsession].fieldlen = mysql_fetch_lengths (sql[sqlsession].result);
--count;
}
}
}

19
__whilerow.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef ____whilerow_h__
#define ____whilerow_h__
#include "Tag.h"
#include "ZString.h"
#include "MString.h"
namespace jet {
class __whilerow : public Tag {
public:
__whilerow(coreutils::ZString &in, coreutils::MString &parent, Global &global);
};
}
#endif

View File

@ -5,7 +5,9 @@
$[nonexistant]
<mysql host="localhost" database="barant" user="barant" password="uversa" sessionid="1">
<sql sessionid="1">select * from testdata</sql>
$[1.id] $[1.text] $[1.value]
<whilerow name="index" count="10" sessionid="1">
$[1.id] $[1.text] $[1.value]
</whilerow>
</mysql>
<set name="ix" value="1" />
<set name="theexpr" expr="SUBSTRING('abcdefg', 1, 3)" />