2019-09-24 22:28:59 +00:00
|
|
|
#if __has_include(<mysql.h>)
|
|
|
|
#include <mysql.h>
|
2018-07-25 11:29:26 +00:00
|
|
|
#else
|
2017-01-24 21:07:08 +00:00
|
|
|
#include <mysql/mysql.h>
|
2018-07-25 11:29:26 +00:00
|
|
|
#endif
|
2017-01-13 20:37:37 +00:00
|
|
|
#include <mysqlxx/Row.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace mysqlxx
|
|
|
|
{
|
|
|
|
|
|
|
|
Value Row::operator[] (const char * name) const
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
unsigned n = res->getNumFields();
|
|
|
|
MYSQL_FIELDS fields = res->getFields();
|
2017-01-13 20:37:37 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (unsigned i = 0; i < n; ++i)
|
|
|
|
if (!strcmp(name, fields[i].name))
|
|
|
|
return operator[](i);
|
2017-01-13 20:37:37 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
throw Exception(std::string("Unknown column ") + name);
|
2017-01-13 20:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|