mysql efforts...
This commit is contained in:
1 parent
3ba81a7d0a
commit
7453db9bd9
12 files changed
+120
-13
No files matched your search
+34
@@ -1,10 +1,44 @@
|
||||
#include "__mysql.h"
|
||||
#include "Exception.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__mysql::__mysql(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
|
||||
processContainer(container);
|
||||
|
||||
if(!variableDefined("host"))
|
||||
coreutils::Exception("host must be specified for mysql tag.");
|
||||
if(!variableDefined("database"))
|
||||
coreutils::Exception("database must be specified for mysql tag.");
|
||||
if(!variableDefined("user"))
|
||||
coreutils::Exception("user must be specified for mysql tag.");
|
||||
if(!variableDefined("password"))
|
||||
coreutils::Exception("password must be specified for mysql tag.");
|
||||
|
||||
sessionId = variables["sessionid"];
|
||||
|
||||
global.addSession(sessionId, this);
|
||||
|
||||
mysql = mysql_init(NULL);
|
||||
mysql = mysql_real_connect(mysql, variables["host"].c_str(), variables["user"].c_str(), variables["password"].c_str(), variables["database"].c_str(), 0, NULL, 0);
|
||||
|
||||
}
|
||||
|
||||
__mysql::~__mysql() {
|
||||
global.removeSession(sessionId);
|
||||
mysql_free_result(result);
|
||||
mysql_close(mysql);
|
||||
}
|
||||
|
||||
void __mysql::query(coreutils::MString query) {
|
||||
mysql_real_query(mysql, query.getData(), query.getLength());
|
||||
result = mysql_store_result(mysql);
|
||||
if(result) {
|
||||
row = mysql_fetch_row(result);
|
||||
fieldLength = mysql_fetch_lengths(result);
|
||||
qFields = mysql_num_fields(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user